spread for asp.net developer’s guide -...
TRANSCRIPT
-
Developer's Guide
Thisguideprovidesintroductoryconceptualmaterialandhow-toexplanationsforroutinetasksfordevelopersusingSpreadforASP.NET.ItdescribeshowanapplicationdeveloperwouldusethepropertiesandmethodsinSpreadtocreatespreadsheetsandgridsonWebForms,bindtodatabases,andcustomizethecomponentforyourapplication.
GettingStartedUnderstandingtheProductWorkingwiththeSpreadDesignerCustomizingtheAppearanceCustomizingUserInteractionCustomizingwithCellTypesManagingDataBindingManagingDataintheComponentManagingFormulasManagingFileOperationsUsingSheetModelsMaintainingStateWorkingwiththeChartControlUsingTouchSupportwiththeComponent
ForcompleteAPIreferenceinformation,refertotheAssemblyReference(on-linedocumentation).
Foracompletelistofdocumentation,refertotheSpreadforASP.NETDocumentation(on-linedocumentation).
Spread for ASP.NET Developer’s Guide 0
Copyright © GrapeCity, Inc. All rights reserved.
-
1 Table of Contents
Developer'sGuide 0
1. TableofContents 1-16
GettingStarted 17
HandlingInstallation 17
InstallingtheProduct 17
LicensingaTrialProjectafterInstallation 17
End-UserLicenseAgreement 17-18
CreatingaBuildLicense 18-19
HandlingRedistribution 19-20
ProductRequirements 20
HandlingVariationsInWindowsSettings 20-21
WorkingwiththeComponent 21
AddingaComponenttoaWebSiteusingVisualStudio2015or2017 21-24
AddingaComponenttoaWebSiteusingVisualStudio2013 24-28
AddingaComponenttoaWebSiteusingVisualStudio2012 28-30
AddingaComponenttoaWebSiteusingVisualStudio2010 30-33
AddingandUsingJavaScriptIntellisense 33
AddingJavaScriptIntelliSenseforVisualStudio2012 33-35
AddingJavaScriptIntelliSenseforVisualStudio2010 35-36
UnderstandingBrowserSupport 36-38
UnderstandingPartsoftheComponentInterface 38-39
WorkingwithCollectionEditors 39
WorkingwithWebParts 40
WorkingwithWindowsAzure 40
WorkingwithMicrosoftASP.NETMVC5 40-44
WorkingwithMicrosoftASP.NETMVC3 44-48
CopyingSharedAssembliestoLocalFolder 48-49
WorkingwithStronglyTypedDataControls 49
Spread for ASP.NET Developer’s Guide 1
Copyright © GrapeCity, Inc. All rights reserved.
-
GettingMorePractice 49
UnderstandingProceduresintheDocumentation 49-51
GettingTechnicalSupport 51
UnderstandingtheSpreadWizard 51
StartingtheSpreadWizard 51-52
UsingtheSpreadWizard 52-53
Tutorial:CreatingaCheckbookRegister 53
AddingSpreadtotheCheckbookProject 53
AddingSpreadtoaProject 53-55
SettingUptheRowsandColumnsoftheRegister 55-57
SettingtheCellTypesoftheRegister 57-59
AddingFormulastoCalculateBalances 59-60
UnderstandingtheProduct 61
ProductOverview 61-62
FeaturesOverview 62-63
AJAXSupport 63
ASP.NETAJAXExtenders 63-64
Built-InFunctions 64
CellTypes 64-65
ChartControl 65
Client-SideScripting 65
ConditionalFormatting 65
ContextMenu 65
CornerCustomization 65-66
CustomizedAppearance(Skins) 66
DataBinding 66
FootersforColumnsorGroups 66
FrozenRowsandColumns 66
GoalSeeking 66
Grouping 66
Spread for ASP.NET Developer’s Guide 2
Copyright © GrapeCity, Inc. All rights reserved.
-
HeaderswithMultipleColumnsandRows 66
HierarchicalDisplay 66-67
ImportandExportCapabilities 67
LoadonDemand 67
Multiple-LineColumns 67
MultipleSheets 67
PDFSupport 67
Printing 67-68
RowFiltering 68
RowPreview 68
RowTemplateEditor 68
SearchingFeatures 68
SortingCapabilities 68
SpannableCells 68
Sparklines 68
SpreadDesigner 68-69
SpreadWizard 69
ThemeRoller 69
TitleandSubtitle 69
TouchSupport 69
ValidationControls 69
ConceptsOverview 69
ShortcutObjects 69-71
ObjectParentage 71
UnderlyingModels 72-73
CellTypes 73
SheetViewversusFpSpread 73
FormattedversusUnformattedData 73-74
Zero-BasedIndexing 74
Client-SideScripting 74
Spread for ASP.NET Developer’s Guide 3
Copyright © GrapeCity, Inc. All rights reserved.
-
MaintainingState 74
NamespacesOverview 75
WorkingwiththeSpreadDesigner 76
StartingtheSpreadDesigner 76
UnderstandingtheSpreadDesignerInterface 76-77
SpreadDesignerMenus 77-78
FileMenu 78
HomeMenu 78-79
InsertMenu 79
DataMenu 79
ViewMenu 79
SettingsMenu 80
ChartToolsMenu 80
SparklinesMenu 80-81
SpreadDesignerToolbars 81
SpreadDesignerEditors 81
AlternatingRowsEditor 81-82
Cells,Columns,andRowsEditor 82-83
ContextMenuCollectionEditor 83-86
DataKeyNames(StringCollection)Editor 86-87
FormulaEditor 87-88
GroupInfoCollectionEditor 88-89
HeaderEditor 89-90
NamedStyleCollectionEditor 90-91
RowTemplateEditor 91-92
SheetSkinEditor 92-93
SheetViewCollectionEditor 93-94
SpreadDesignerContextMenus 94-95
UsingtheSpreadDesigner 95-96
Spread for ASP.NET Developer’s Guide 4
Copyright © GrapeCity, Inc. All rights reserved.
-
CustomizingSheets,Rows,andColumnsinSpreadDesigner 96-97
CustomizingCellsinSpreadDesigner 97-99
AddingFormulastoCells 99-101
SavingandOpeningDesignFiles 101-102
ApplyingChangesandClosingSpreadDesigner 102
CustomizingUserInteraction 103
CustomizingInteractionwiththeOverallComponent 103
DisplayingScrollBars 103-104
DisplayingScrollBarTextTips 105
CustomizingtheScrollBarColors 105-106
AllowingLoadonDemand 106-108
CustomizingInteractionBasedonEvents 108
HandlingtheTabKey 108
CustomizingtheGraphicalInterface 109-110
SearchingforDatawithCode 110-111
AddingaContextMenu 111-113
WorkingwithAJAX 113
EnablingAJAXsupport 113-114
UsingASP.NETAJAXExtenders 114-115
CustomizingtheToolbars 115
CustomizingtheCommandBarontheComponent 115-117
CustomizingtheCommandButtons 117-120
ChangingtheCommandButtonImages 120-122
HidingaSpecificCommandButton 122-123
DisplayingtheSheetNames 123-125
CustomizingPageNavigation 125-128
CustomizingPageNavigationButtonsontheClient 128-129
CustomizingtheHierarchyBar 129-130
CustomizingInteractionwithRowsandColumns 130
AllowtheUsertoMoveColumns 130-131
Spread for ASP.NET Developer’s Guide 5
Copyright © GrapeCity, Inc. All rights reserved.
-
AllowingtheUsertoResizeRowsorColumns 131-132
FreezingRowsandColumns 132-133
SettingupRowEditTemplates 133-134
SettingupPreviewRows 134-135
ManagingFilteringofRowsofUserData 135-136
CreatingFilteredRowsandSettingtheAppearance 136-140
CustomizingSimpleFilteringofRowsofUserData 140
UsingRowFiltering 140-141
CustomizingtheListofFilterItems 141-142
CreatingaCompletelyCustomFilter 142-143
UsingEnhancedFiltering 143-145
UsingtheFilterBar 145-148
CustomizingGroupingofRowsofUserData 148
UsingGrouping 148-149
AllowingtheUsertoGroupRows 149-150
SettingtheAppearanceofGroupedRows 150-152
CustomizingtheGroupBar 152-153
CreatingaCustomGroup 153
CompatibilitywithOtherFeatures 153-154
CustomizingSortingofRowsofUserData 154-155
AllowingUserSorting 155-156
CustomizingInteractionwithCells 156
AddingaNotetoaCell 156-157
AddingaTagtoaCell 157-159
LockingaCell 159-161
UsingConditionalFormattinginCells 161
CreatingConditionalFormattingwithRules 161-162
ColorScaleRules 162-163
DataBarRule 163-165
HighlightingRules 165-167
Spread for ASP.NET Developer’s Guide 6
Copyright © GrapeCity, Inc. All rights reserved.
-
IconSetRule 167-168
ToporAverageRules 168-169
ConditionalFormattingofCells 169-170
CustomizingSelectionsofCells 170
SpecifyingWhattheUserCanSelect 170-172
WorkingwithSelectionsofCells 172-173
CustomizingtheAppearanceofSelections 173-174
ManagingPrinting 174
PrintingaSpreadsheet 174-175
AddingHeadersandFooterstoPrintedPages 175
CustomizingtheAppearance 176
CustomizingtheAppearanceoftheOverallComponent 176
CustomizingtheDimensionsoftheComponent 176-177
CustomizingtheOutlineoftheComponent 177-178
CustomizingtheDefaultInitialAppearance 178-179
ResettingPartsoftheInterface 179-180
UsingthejQueryThemeRollerwithSpread 180-181
CustomizingtheAppearanceoftheSheet 181-182
WorkingwiththeActiveSheet 182
WorkingwithMultipleSheets 182-183
AddingaSheet 183-184
RemovingaSheet 184-185
ShowingorHidingaSheet 185-186
SettingtheBackgroundColoroftheSheet 186-187
AddingaTitleandSubtitletoaSheet 187-188
CustomizingthePageSize(RowstoDisplay) 188-190
DisplayingGridLinesontheSheet 190-191
CustomizingtheSheetCorner 191-193
DisplayingaFooterforColumnsorGroups 193-197
Spread for ASP.NET Developer’s Guide 7
Copyright © GrapeCity, Inc. All rights reserved.
-
CreatingaSkinforSheets 197-199
ApplyingaSkintoaSheet 199-200
CustomizingtheAppearanceofRowsandColumns 200
CustomizingtheNumberofRowsorColumns 200-201
AddingaRoworColumn 201-202
RemovingaRoworColumn 202-204
ShowingorHidingRowsorColumns 204-205
SettingtheRowHeightorColumnWidth 205-206
SettingtheTopRowtoDisplay 206-207
CreatingAlternatingRows 207-208
CreatingRowTemplates(Multiple-LineColumns) 208-212
CustomizingtheAppearanceofHeaders 212-213
CustomizingtheStyleofHeaderCells 213-214
ShowingorHidingHeaders 214-216
CustomizingtheDefaultHeaderLabels 216-218
CustomizingHeaderLabelText 218-219
SettingtheSizeofHeaderCells 219-220
CustomizingtheHeaderEmptyAreas 220-221
CreatingaHeaderwithMultipleRowsorColumns 221-224
CreatingaSpaninaHeader 224-225
CustomizingtheAppearanceofaCell 225-226
WorkingwiththeActiveCell 226
CustomizingtheColorsofaCell 226-228
AligningCellContents 228-229
CustomizingCellBorders 229-230
CustomizingtheMarginsandSpacingoftheCell 230-232
CreatingandApplyingaCustomStyleforCells 232-234
AssigningaCascadingStyleSheettoaCell 234-235
CreatingaRangeofCells 235-236
SpanningCells 236-238
Spread for ASP.NET Developer’s Guide 8
Copyright © GrapeCity, Inc. All rights reserved.
-
AllowingCellstoMergeAutomatically 238-240
UsingSparklines 240-241
AddingaSparklinetoaCell 241-243
CustomizingMarkersandPointers 243-245
SpecifyingHorizontalandVerticalAxes 245-246
WorkingwithSparklines 246-247
CustomizingwithCellTypes 248-249
UnderstandingHowCellTypesWork 249
UnderstandingCellTypeBasics 249
UnderstandingHowCellTypesDisplayData 249-251
UnderstandingHowCellTypeAffectsModelData 251-252
DeterminingtheCellTypeofaCell 252-253
WorkingwithEditableCellTypes 253
SettingaCurrencyCell 253-255
LimitingValuesforaCurrencyCell 255-256
SettingaDate-TimeCell 256-257
DisplayingaCalendarinaDate-TimeCell 257-258
SettingaDoubleCell 258-259
SettingaGeneralCell 259-260
SettinganIntegerCell 260-261
SettingaPercentCell 261-262
SettingaRegularExpressionCell 262-263
SettingaTextCell 263-264
WorkingwithGraphicalCellTypes 264
SettingaButtonCell 264-266
SettingaCheckBoxCell 266-268
SettingaComboBoxCell 268-270
SettingaHyperlinkCell 270-272
SettinganImageCell 272-273
SettingaLabelCell 273-274
Spread for ASP.NET Developer’s Guide 9
Copyright © GrapeCity, Inc. All rights reserved.
-
SettingaListBoxCell 274-275
SettingaMultiple-ColumnComboBoxCell 275-276
SettingaRadioButtonListCell 276-278
SettingaTagCloudCell 278-280
WorkingwithASP.NETAJAXExtenderCellTypes 280-281
SettinganAutomatic-CompletionCell 281
SettingaCalendarCell 281-282
SettingaComboBoxCell 282
SettingaFilteredTextCell 282
SettingaMaskedEditCell 282-283
SettingaMutuallyExclusiveCheckBoxCell 283
SettingaNumericSpinCell 283
SettingaRatingCell 283-284
SettingaSliderCell 284
SettingaSlideShowCell 284
SettingaTextBoxwithWatermarkCell 284-285
UsingValidationControls 285-289
ManagingDataBinding 290
DataBindingOverview 290-291
BindingtoaDataSource 291-292
BindingtoaRange 292-294
ModelDataBindinginASP.NET4.5 294-298
SettingtheCellTypesforBoundData 298-299
DisplayingDataasaHierarchy 299-302
HandlingRowExpansion 302-303
AddinganUnboundRow 303-304
LimitingPostbacksWhenUpdatingBoundData 304
Tutorial:BindingtoaCorporateDatabase 304
UsingSpreadwithVisualStudio2012andtheSQLDataSource 304-305
Spread for ASP.NET Developer’s Guide 10
Copyright © GrapeCity, Inc. All rights reserved.
-
UsingSpreadwiththeAccessDataSourceControl 305-306
AddingSpreadtoaDataBindProject 306
SettinguptheDatabaseConnection 306-307
SpecifyingtheDatatoUse 307-308
CreatingtheDataSet 308-309
BindingSpreadtotheDatabase 309-310
ImprovingtheDisplaybyChangingtheCellType 310
ManagingDataintheComponent 311
SavingDatatotheServer 311
PlacingandRetrievingData 311
HandlingDataUsingSheetMethods 311-314
HandlingDataUsingCellProperties 314
Server-SideScripting 314
UnderstandingEffectsofClient-SideValidation 314-315
UnderstandingPostbackandPageLoadEvents 315-316
UnderstandingtheEffectofModeonEvents 316-317
ManagingFormulas 318
PlacingaFormulainCells 318-319
SpecifyingaCellReferenceStyleinaFormula 319-320
UsingaCircularReferenceinaFormula 321-322
NestingFunctionsinaFormula 322
FindingaValuewithGoalSeeking 322-323
RecalculatingandUpdatingFormulasAutomatically 323-324
CreatingaCustomFunction 324-325
CreatingaCustomName 325-326
ManagingFileOperations 327
SavingDatatoaFile 327
SavingtoaSpreadXMLFile 327-328
SavingtoanExcelFile 328-329
SavingtoaTextFile 329-330
Spread for ASP.NET Developer’s Guide 11
Copyright © GrapeCity, Inc. All rights reserved.
-
SavingtoanHTMLFile 330-331
SavingtoaPDFFile 331
SavingtoPDFMethods 331-332
SettingPrintInfoClassProperties 332
SettingSmartPrintOptions 332-334
SettingHeadersandFooters 334-338
OpeningExistingFiles 338
OpeningaSpreadXMLFile 338-339
OpeninganExcel-FormattedFile 339-340
OpeningaTextFile 340
UsingSheetModels 341-342
UnderstandingtheModels 342
UnderstandingHowtheModelsWork 342-344
CustomizingModels 344
UnderstandingtheAxisModel 344-345
UnderstandingtheDataModel 345-348
UnderstandingtheSelectionModel 348
UnderstandingtheSpanModel 348
UnderstandingtheStyleModel 348-351
UnderstandingtheOptionalInterfaces 351
CreatingaCustomSheetModel 352-353
MaintainingState 354
StateOverview 354
SavingDatatotheViewState 354-356
SavingDatatotheSessionState 356-358
SavingDatatoanSQLDatabase 358
LoadingDataforEachPageRequest 358-364
WorkingwiththeChartControl 365
UnderstandingandCustomizingCharts 365
ChartUserInterfaceElements 365-366
Spread for ASP.NET Developer’s Guide 12
Copyright © GrapeCity, Inc. All rights reserved.
-
ChartTypesandViews 366-367
PlotTypes 367
YPlotTypes 368
AreaCharts 368-370
BarCharts 370-373
LineCharts 373-374
MarketData(High-Low)Charts 374-376
PointCharts 376-377
StripeCharts 377-378
XYPlotTypes 378
BubbleCharts 378-379
LineCharts 379
PointCharts 379-380
StripeCharts 380
XYZPlotTypes 380-381
PointCharts 381-382
LineCharts 382-383
SurfaceCharts 383-384
StripeCharts 384
PiePlotTypes 384
DoughnutCharts 385
PieCharts 385
PolarPlotTypes 386
PointCharts 386-387
LineCharts 387-388
AreaCharts 388-389
StripeCharts 389
RadarPlotTypes 389-390
PointCharts 390-391
Spread for ASP.NET Developer’s Guide 13
Copyright © GrapeCity, Inc. All rights reserved.
-
LineCharts 391-392
AreaCharts 392
StripeCharts 392-393
DataPlotTypes 393-394
Series 394-395
Walls 395-396
AxisandOtherLines 396-398
FillEffects 398-401
ElevationandRotation 401-402
Lighting,Shapes,andBorders 402-405
Size-Height,Width,andDepth 405-406
Labels 406-407
Legends 407-408
CreatingCharts 408
CreatingPlotTypes 408
CreatingaYPlot 408-410
CreatinganXYPlot 410-413
CreatinganXYZPlot 413-416
CreatingaPiePlot 416-418
CreatingaPolarPlot 418-421
CreatingaRadarPlot 421-423
CombiningPlotTypes 423-425
ConnectingtoData 425
UsingaBoundDataSource 425-427
UsinganUnboundDataSource 427-428
UsingRawDataVersusRepresentedData 428-429
UsingtheChartDesigner 429
OpeningtheChartDesigner 429-430
CreatingaChartControl 430-433
UsingtheChartCollectionEditors 433
Spread for ASP.NET Developer’s Guide 14
Copyright © GrapeCity, Inc. All rights reserved.
-
LabelAreaCollectionEditor 433-434
LegendAreaCollectionEditor 434
PlotAreaCollectionEditor 434-435
LightCollectionEditor 435-436
SeriesCollectionEditor 436
UsingtheSpreadDesigner 436-437
UsingtheChartControl 437
CreatingtheChartControl 437-439
RenderingorSavingtheChartControltoanImage 439
LoadingorSavingtheChartControltoXML 439-440
UsingtheChartControlinSpread 440
CreatingtheChartControlwithCode 440-443
BindingtheChartControlwithSpread 443-444
MovingandResizingtheChartControlinSpread 444-445
SelectingtheChartControlinSpread 445-446
SettingtheChartControlBorderinSpread 446-447
SettingtheChartViewType 447-448
UsingtheChartContextMenu 448-449
UsingTouchSupportwiththeComponent 450
UnderstandingTouchSupport 450
UnderstandingTouchGestures 450
UsingTouchSupport 450-451
UsingtheTouchMenuBar 451-452
UsingTouchSupportwithAutoFit 452
UsingTouchSupportwithCharts 452
UsingTouchSupportwithEditableCells 452-453
UsingTouchSupportwithFiltering 453-454
UsingTouchSupportwithGrouping 454-456
UsingTouchSupportwhenMovingColumns 456-457
UsingTouchSupportwhenResizingColumnsorRows 457-459
Spread for ASP.NET Developer’s Guide 15
Copyright © GrapeCity, Inc. All rights reserved.
-
UsingTouchSupportwithScrolling 459-460
UsingTouchSupportwithSelections 461-462
UsingTouchSupportwithSorting 462-463
2. Index 464-502
Spread for ASP.NET Developer’s Guide 16
Copyright © GrapeCity, Inc. All rights reserved.
-
Getting Started
Thistopicdescribeshowtogetstartedwiththecomponent.Itincludes:
HandlingInstallationWorkingwiththeComponentGettingMorePracticeUnderstandingtheSpreadWizardTutorial:CreatingaCheckbookRegister
Handling Installation
Herearethetasksforinstallingtheproductfordevelopmentandforredistribution.
InstallingtheProductLicensingaTrialProjectafterInstallationEnd-UserLicenseAgreementCreatingaBuildLicenseHandlingRedistributionProductRequirementsHandlingVariationsinWindowsRegionalSettings
Installing the Product
InstallationinstructionsandalistofinstalledfilesforSpreadforASP.NETisprovidedintheReadMefilethataccompaniesthisproduct.ToviewtheReadMefile,dooneofthefollowing:
1. FromtheStartmenuchoosePrograms->GrapeCity->Spread.NET11->ASP.NET->SpreadASPReadMe.SelecttheReadMeundertheGrapeCitynameontheStartscreenwithMicrosoftWindows8,8.1,or10.
2. Ifyouperformedadefaultinstallation,inWindowsExplorerbrowseto\ProgramFiles\GrapeCity\Spread.NET11\Docs\ASP.NETanddouble-clickthereadme.chmfile.
YoucanalsoaccesstheReadMeonthewebsite.
Licensing a Trial Project after Installation
TolicenseASP.NETprojectsmadewiththetrialversiondothefollowing:
1. EnsurethatSpreadislicensedonthemachinebyfollowingtheinstallationstepsintheReadMe.2. OpentheprojectinMicrosoftVisualStudio.3. OpentheVisualStudioBuildmenuandselectRebuildSolution.4. Thewebapplicationisnowlicensedandnoevaluationbannersappearwhenyourunit.Youcandistributethe
Webapplicationtounlicensedmachinesandnoevaluationbannersappear.
ForlicensingWebSiteapplications,opentheVisualStudioBuildmenuandselectBuildRuntimeLicensestocreatetheApp_Licenses.dllfile.
End-User License Agreement
TheGrapeCitylicensinginformation,includingtheGrapeCityend-userlicenseagreements,frequentlyaskedlicensingquestions,andtheGrapeCitylicensingmodel,isavailableonlineathttps://www.grapecity.com/en/licensing/spread
Spread for ASP.NET Developer’s Guide 17
Copyright © GrapeCity, Inc. All rights reserved.
http://sphelp.grapecity.com/WebHelp/SpreadNET11ReadMe/webframe.htmlhttp://sphelp.grapecity.com/WebHelp/SpreadNET11ReadMe/webframe.htmlhttps://www.grapecity.com/en/licensing/spread
-
andhttps://www.grapecity.com/en/legal/eula.
Creating a Build License
Youcancreateabuildlicensetouseonabuildmachine.
Licensesarebuiltusingthelicensecompilertool(lc.exe)toproduceaspecialresourcefilewiththe.licensesfileextension.VisualStudioVB.NETandC#projectsautomaticallyhandlecompilingthelicenses.licxintheprojecttoproducethe.licensesresourcefile,whichislinkedintothetargetexecutable.Thecomponents’run-timelicensekeysinthatlicensesresourcefileareloadedandverifiedwhenthefirstinstanceofeachcomponentwiththeLicenseProviderattributeiscreatedintheapplication.Youcanremovethelicenses.licxfromyourVisualStudioprojectandaddthe.licensesresourceinitsplaceusingthefollowingsteps:
1. Buildtheprojectusingthelicensedcomponentsonadevelopermachinewhichislicensedfordevelopmentwithallthecomponentsreferencedintheproject(thiscreatesthe.licensesresource).
2. Findthelicenses.licxintheSolutionExplorerwindow.YoucanusetheShowAllFilestoolbarbuttontoseeitorexpandthePropertiesfolder.
3. Right-clickthelicenses.licxintheSolutionExplorerwindow,andthenselectExcludeFromProject.
4. UseWindowsExplorer(outsideVisualStudio)tofindthe.licensesfileintheobj\{configuration}folder(obj\Debugorobj\Release).Thefileshouldhavethename{target}.{ext}.licenses(forexample:project1.exe.licenses).
5. Copythatfiletotheprojectfolderandrenameittoremovethetargetname(renameitfrom{target}.{ext}.licensesto{ext}.licenses).Forexample:project1.exe.licensestoexe.licenses.
6. IntheVisualStudioSolutionExplorerwindow,findthe{ext}.licenses(youmightneedtorefreshthewindow),thenright-clickthefileandselectIncludeInProject.
Spread for ASP.NET Developer’s Guide 18
Copyright © GrapeCity, Inc. All rights reserved.
https://www.grapecity.com/en/licensing/spreadhttp://spread.grapecity.com/Pages/EULA/
-
7. ChangetheBuildActionforthe{ext}.licensesfromContenttoEmbeddedResource.
8. Theprojectcannowbebuiltwithoutrequiringadeveloperlicenseonthemachine,sincethelicensehasalreadybeenbuiltandlinkedintotheproject.
Notethefollowingrestrictions:
Thelicensesresourcecontainsthenameofthetargetmoduleencodedinitscontents,sothatlicensesresourceisspecifictothatparticularproject.Thestepsdescribedabovewillnotbypassanypartofthedesign-timelicenseenforcement.Thedeveloperlicenseisstillrequiredtoopenformscontaininginstancesofthelicensedcontrols.Ifthelicensedcomponentsintheprojectchange,thenspecialcareshouldbetaken.Thelicenses.licxshouldbeaddedbacktotheprojectfirst,sothatitdoesnotgetrecreated(empty)byVisualStudioandcausetypereferences(andembeddedlicensesintheresource)tobelost.Afterthenewlicensedcomponentsareaddedorchangedinthelicx,theabovestepsshouldberepeated.Theabovestepsonlyapplyfor.NETmanagedcodeapplicationswhichusethestandard.NETFrameworkcomponentlicensingmodel(ActiveXcontrollicensinginmanaged.NETapplicationsdoesnotusethismechanism).
Handling Redistribution
PleasereviewthisinformationconcerningredistributionofSpreadforASP.NETwithyourapplication.
ServerRequirements
YoumustdeploytoaMicrosoftInternetInformationserver.
Spread for ASP.NET Developer’s Guide 19
Copyright © GrapeCity, Inc. All rights reserved.
-
ServerFiles
PlacetheassembliesthatcomewithSpreadforASP.NETineitheryourserver'sglobalassemblycache(GAC)orinyourapplicationdirectory's\binfolderunderthewwwrootdirectoryonyourserver.
Placethefollowingassembliesonyourserver:
FarPoint.Web.Spread.dllFarPoint.CalcEngine.dllFarPoint.Excel.dllFarPoint.PDF.dllFarPoint.Web.Chart.dll(ifyouusetheChartcontrolorSparklines)FarPoint.Web.Spread.Extender.dll(ifyouusetheextenderclasses)System.Web.Extensions.dll(ifyouusetheFarPoint.Web.Spread.Extender.dll)AjaxControlToolkit.dll(ifyouusetheFarPoint.Web.Spread.Extender.dll)FarPoint.Mvc.Web.Spread.dll(ifyouuseSpreadinanMVC3project)
Placethefp_clientfolder(installedinSpread.NET\ASP.NET\..\fp_client)anditssubfoldersprovidedwithSpreadforASP.NETunderyourserver'swwwrootdirectory,or,ifyouwishtoputitelsewhere,setupavirtualdirectoryinIISManagertopointtothelocationofthatfolder'scontents.
Thefp_clientfoldercanalsobeplacedinthewebapplicationdirectory.Thefollowingcodewouldneedtobeaddedtothewebconfigfile.Forexample:
...
BeawarethatSpreadforASP.NETcreatesaWebservercontrolthatservesupHTMLpagesforclientsanditalsoputsHTCfilesinadirectoryontheclientmachineforclient-sidescriptingcapability.
SpreadforASP.NETusesjQuery2.x.IfthewebpageorwebapplicationusesjQuery2.0orhigher,SpreadusesthatversionofjQuery.IfthewebpageusesjQuery1.9orearlier,SpreadusesjQuery2.xinternallyanddoesnotconflictwiththewebpageversionofjQuery.
PermissionRequirements
IfyouusetheSpreadcontrolonmediumtrustwebsites,youneedtoaddSerializationFormatterandReflectionpermissionstothemachineconfigfile,web_mediumtrust.config.TheSecurityPermissionneedstheUnmanagedCodeandSerializationFormatterflags.Forexample:
Product Requirements
Fordevelopingapplicationswiththe.NET4.0versionofSpreadforASP.NET,youmusthavethefollowingsystemitems:
Operating SystemOneofthefollowing:
MicrosoftWindows2003ServerMicrosoftWindows2008ServerMicrosoftWindows2012ServerMicrosoftWindowsXPProfessionalMicrosoftWindowsVistaMicrosoftWindows7MicrosoftWindows8MicrosoftWindows8.1MicrosoftWindows10
SoftwareReleaseversionoftheMicrosoft.NET4.0Framework.MicrosoftInternetInformationServices(IIS)SQLServerortheSQLServerdesktopenginethatshipswithVisualStudio.NETinstalledonyourmachinetobeabletorunsomeofthedatabindingsamplesTheSpreadextenderrequirestheAJAXControlToolkitTheSpreadDesignerrequiresMicrosoftInternetExplorer(IE)7orhigherandtheMicrosoft.mshtml.dll.
Handling Variations in Windows Regional Settings
TheSpreadcomponentreadstheWindowsregionalsettingsoroptions,whicharesetbytheuserthroughtheControl
Spread for ASP.NET Developer’s Guide 20
Copyright © GrapeCity, Inc. All rights reserved.
-
Panel,butduetovariationsinhowWindowshandlesthosesettings,yourusermightexperienceunexpectedresults.
IngeneralinWindowsoperatingsystems,theSpreadcomponentdoesnotrecognizechangesmadetotheWindowsregionalsettingsuntilyourestartyourdevelopmentenvironmentoryourapplicationorperformanyoperationthatunloadsandreloadsthecurrentassemblyanddependentassemblies.Thisisbecausehandlingtheregionalsettingsisveryprocessorintensive.Tooptimizeperformancethesesettingsarenotcheckedeachtimeasimpleoperationisperformed.
InmostWindowsoperatingsystems,theregionaloptionsarereadfromthesystemregistry.Incertainsituations,Windowsdoesnotclearpreviousregionaloptionswhenreadingchangesfromthesystemregistry.Beawareofthiswhenworkingwithregionalsettings.
Working with the Component
Herearethetasksinvolvedwithstartingtoworkwiththecomponent.
AddingaComponenttoaWebSiteusingVisualStudio2015or2017AddingaComponenttoaWebSiteusingVisualStudio2013AddingaComponenttoaWebSiteusingVisualStudio2012AddingaComponenttoaWebSiteusingVisualStudio2010AddingandUsingJavaScriptIntelliSenseUnderstandingBrowserSupportUnderstandingPartsoftheComponentInterfaceWorkingwithCollectionEditorsWorkingwithWebPartsWorkingwithWindowsAzureWorkingwithMicrosoftASP.NETMVC5WorkingwithMicrosoftASP.NETMVC3CopyingSharedAssembliestoLocalFolderWorkingwithStronglyTypedDataControls
Adding a Component to a Web Site using Visual Studio 2015 or 2017
UsethefollowingstepstoaddaSpreadcomponenttoaWebForminVisualStudio.YoucaneitheropenanexistingWebSiteorcreateanewone.
Spread,asachildcontrolofthepage,isaffectedbythestylesettingsonthatpage(similartoplacingatableonawebform,andsettingamasterCSSforeverythinginsidethepage).IfyoucreateadefaultwebapplicationwithVisualStudio2010orhigher,thedefaultmasterpagecontainsCSSstylesettings.Spread,onceplacedonthisdefaultpage,canbeaffectedbythestylesettingsandthelayoutmaychange.AvoidthefollowingHTMLtagstopreventthelayoutchange:TD,TH,TABLE,INPUT,andTEXTAREA.
Step1.StartVisualStudio.
Step2.CreateanewWebsite.
1. SelectNewProjectorfromtheFilemenu,chooseNew,WebSite.2. UnderTemplates,selectWebunderVisualBasicorVisualC#.
Spread for ASP.NET Developer’s Guide 21
Copyright © GrapeCity, Inc. All rights reserved.
-
3. SelectASP.NETWebApplication.4. Specifyalocationandnamefortheproject.5. SelectOK.6. SelectatemplatesuchasEmpty.
Spread for ASP.NET Developer’s Guide 22
Copyright © GrapeCity, Inc. All rights reserved.
-
7. SelectOK.IfyourprojectdoesnotdisplaytheSolutionExplorer,fromtheViewmenu,chooseSolutionExplorer.Ifyouusedanemptysite,youmaywishtoaddawebformtotheproject(chooseAdd,WebFormafterright-clickingontheprojectnameintheSolutionExplorer).
SpecifytheItemname.SelectOK.
Step3.AddtheFpSpreadcomponenttothetoolboxifthecomponentisnotdisplayedinthetoolbox.
1. IftheToolboxisnotdisplayed,fromtheViewmenuchooseToolbox.2. OncetheToolboxisdisplayed,lookintheGrapeCitySpreadcategory(orinothercategoriesifyouhaveinstalled
Spreadandplacedthetoolboxiconinadifferentcategory).3. IftheFpSpreadcomponentisnotintheToolbox,right-clickintheToolbox,andfromthepop-upmenuchooseChooseItems.
4. IntheChooseToolboxItemsdialog,clickthe.NETFrameworkComponentstab.5. Inthe.NETFrameworkComponentstab,theFpSpreadcomponentshouldbedisplayedinthelistofcomponents.
Spread for ASP.NET Developer’s Guide 23
Copyright © GrapeCity, Inc. All rights reserved.
-
SelecttheFpSpreadcomponentcheckboxandclickOK.IftheFpSpreadcomponentisnotdisplayedinthelistofcomponents,clickBrowseandbrowsetotheinstallationpathfortheSpreadcomponent.Oncethere,selectFarPoint.Web.Spread.dllandclickOpen.TheFpSpreadcomponentisnowdisplayedinthelistofcomponents.SelectitandclickOK.SelectFarPoint.Web.Chart.dllifyouwishtoaddFpChartatdesigntime.
6. Youcantestthatthecomponenthasbeenaddedbyopeningaprojectandinsertingthecomponent.
Step4.AddtheFpSpreadcomponenttotheWebsite.
1. Withanopenproject,intheToolboxunderWebForms,selecttheFpSpreadcomponent.SelectFpChartifyouwishtoaddthechartatdesigntime.
2. OnyourWebFormspage,drawanFpSpreadcomponentbydraggingarectanglethesizethatyouwouldliketheinitialcomponentorsimplydouble-clickonthepage.
3. TheFpSpreadcomponentappears(asshowninthisVisualStudioproject).
Adding a Component to a Web Site using Visual Studio 2013
AddinganFpSpreadcomponenttoaWebForminVisualStudio2013involvesthefollowingstepsofaddingthecomponenttoaWebSite.YoucaneitheropenanexistingWebSiteorcreateanewone.
Spread,asachildcontrolofthepage,isaffectedbythestylesettingsonthatpage(similartoplacingatableonawebform,andsettingamasterCSSforeverythinginsidethepage).IfyoucreateadefaultwebapplicationwithVisualStudio
Spread for ASP.NET Developer’s Guide 24
Copyright © GrapeCity, Inc. All rights reserved.
-
2010orhigher,thedefaultmasterpagecontainsCSSstylesettings.Spread,onceplacedonthisdefaultpage,canbeaffectedbythestylesettingsandthelayoutmaychange.AvoidthefollowingHTMLtagstopreventthelayoutchange:TD,TH,TABLE,INPUT,andTEXTAREA.
Step1.StartVisualStudio2013.
Step2.CreateanewWebsite.
1. SelectNewProjectorfromtheFilemenu,chooseNew,WebSite.2. UnderTemplates,selectWebunderVisualBasicorVisualC#.
3. SelectASP.NETWebApplication.4. Specifyalocationandnamefortheproject.5. ClickOK.6. SelectatemplatesuchasEmpty.
Spread for ASP.NET Developer’s Guide 25
Copyright © GrapeCity, Inc. All rights reserved.
-
7. ClickOK.IfyourprojectdoesnotdisplaytheSolutionExplorer,fromtheViewmenu,chooseSolutionExplorer.Ifyouusedanemptysite,youmaywishtoaddawebformtotheproject(chooseAdd,WebFormafterright-clickingontheprojectnameintheSolutionExplorer).
Spread for ASP.NET Developer’s Guide 26
Copyright © GrapeCity, Inc. All rights reserved.
-
SpecifytheItemname.SelectOK.
Step3.AddtheFpSpreadcomponenttothetoolbox.Thisonlyhastobedoneonce.
1. IftheToolboxisnotdisplayed,fromtheViewmenuchooseToolbox.2. OncetheToolboxisdisplayed,lookintheGrapeCitySpreadcategory(orinothercategoriesifyouhaveinstalled
Spreadandplacedthetoolboxiconinadifferentcategory).3. IftheFpSpreadcomponentisnotintheToolbox,right-clickintheToolbox,andfromthepop-upmenuchooseChooseItems.
4. IntheChooseToolboxItemsdialog,clickthe.NETFrameworkComponentstab.5. Inthe.NETFrameworkComponentstab,theFpSpreadcomponentshouldbedisplayedinthelistofcomponents.SelecttheFpSpreadcomponentcheckboxandclickOK.IftheFpSpreadcomponentisnotdisplayedinthelistofcomponents,clickBrowseandbrowsetotheinstallationpathfortheSpreadcomponent.Oncethere,selectFarPoint.Web.Spread.dllandclickOpen.TheFpSpreadcomponentisnowdisplayedinthelistofcomponents.SelectitandclickOK.SelectFarPoint.Web.Chart.dllifyouwishtoaddFpChartatdesigntime.
6. Youcantestthatthecomponenthasbeenaddedbyopeningaprojectandinsertingthecomponent.
Step4.AddtheFpSpreadcomponenttotheWebsite.
1. Withanopenproject,intheToolboxunderWebForms,selecttheFpSpreadcomponent.SelectFpChartifyouwishtoaddthechartatdesigntime.
2. OnyourWebFormspage,drawanFpSpreadcomponentbydraggingarectanglethesizethatyouwouldliketheinitialcomponentorsimplydouble-clickonthepage.
3. TheFpSpreadcomponentappears(asshowninthisVisualStudio2013project).
Spread for ASP.NET Developer’s Guide 27
Copyright © GrapeCity, Inc. All rights reserved.
-
Adding a Component to a Web Site using Visual Studio 2012
AddinganFpSpreadcomponenttoaWebForminVisualStudio2012involvesthefollowingstepsofaddingthecomponenttoaWebSite.YoucaneitheropenanexistingWebSiteorcreateanewone.
Spread,asachildcontrolofthepage,isaffectedbythestylesettingsonthatpage(similartoplacingatableonawebform,andsettingamasterCSSforeverythinginsidethepage).IfyoucreateadefaultwebapplicationwithVisualStudio2010orhigher,thedefaultmasterpagecontainsCSSstylesettings.Spread,onceplacedonthisdefaultpage,canbeaffectedbythestylesettingsandthelayoutmaychange.AvoidthefollowingHTMLtagstopreventthelayoutchange:TD,TH,TABLE,INPUT,andTEXTAREA.
Step1.StartVisualStudio2012.
Step2.CreateanewWebsite.
1. FromtheFilemenu,chooseNew,WebSite.2. IntheNewWebSitedialog,selectatemplate.Forexample,fromthelistofTemplates,chooseASP.NETWebFormsSiteorASP.NETEmptyWebSite.
3. IntheWeblocationarea,selectHTTPfromthedrop-downbox,andtypealocationpath,suchashttp://localhost/SpWebTest01.Alternatively,youcouldusethedefaultlocationtypeasFileSystem,andthenspecifythecompletepath,butthisrequiressomeadditionalsetupofcopyingthefp_clientfolder.
4. ClickOK.IfyourprojectdoesnotdisplaytheSolutionExplorer,fromtheViewmenu,chooseSolutionExplorer.Ifyouusedanemptysite,youmaywishtoaddawebformtotheproject(chooseAddNewItemafterright-clickingontheprojectnameintheSolutionExplorer).
IntheSolutionExplorer,right-clickontheformname,Default.aspx.Youcanrenameit.ChooseRenamefromthepop-upmenu,thentypethenewformname.
Step3.AddtheFpSpreadcomponenttothetoolbox.Thisonlyhastobedoneonce.
1. IftheToolboxisnotdisplayed,fromtheViewmenuchooseToolbox.
Spread for ASP.NET Developer’s Guide 28
Copyright © GrapeCity, Inc. All rights reserved.
-
2. OncetheToolboxisdisplayed,lookintheGrapeCitySpreadcategory(orinothercategoriesifyouhaveinstalledSpreadandplacedthetoolboxiconinadifferentcategory).
3. IftheFpSpreadcomponentisnotintheToolbox,right-clickintheToolbox,andfromthepop-upmenuchooseChooseItems.
4. IntheChooseToolboxItemsdialog,clickthe.NETFrameworkComponentstab.5. Inthe.NETFrameworkComponentstab,theFpSpreadcomponentshouldbedisplayedinthelistofcomponents.SelecttheFpSpreadcomponentcheckboxandclickOK.IftheFpSpreadcomponentisnotdisplayedinthelistofcomponents,clickBrowseandbrowsetotheinstallationpathfortheSpreadcomponent.Oncethere,selectFarPoint.Web.Spread.dllandclickOpen.TheFpSpreadcomponentisnowdisplayedinthelistofcomponents.SelectitandclickOK.SelectFarPoint.Web.Chart.dllifyouwishtoaddFpChartatdesigntime.
6. Youcantestthatthecomponenthasbeenaddedbyopeningaprojectandinsertingthecomponent.
Step4.AddtheFpSpreadcomponenttotheWebsite.
1. Withanopenproject,intheToolboxunderWebForms,selecttheFpSpreadcomponent.SelectFpChartifyouwishtoaddthechartatdesigntime.
2. OnyourWebFormspage,drawanFpSpreadcomponentbydraggingarectanglethesizethatyouwouldliketheinitialcomponentorsimplydoubleclickonthepage.
3. TheFpSpreadcomponentappears(asshowninthisVisualStudio2012project).
Spread for ASP.NET Developer’s Guide 29
Copyright © GrapeCity, Inc. All rights reserved.
-
Step5.HandlemessageswhenrunningtheWebsite.
1. WhenyouarereadytobuildandruntheWebsite,VisualStudiopopsupanadditionaldialogtoallowyoutochoosebetweenwhethertoenabledebuggingornottoenableit.Anexampleofthedialogappearshere.ClickOK,unlessyouwanttoselecttheotheroptiontorunwithoutdebuggingbeforeclickingOK.
IfyouselecttheFileSystemforthelocation,followtheseadditionalinstructions.
Placethefp_clientfolder(installedinSpread.NET\ASP.NET\..\fp_client)anditssubfoldersprovidedwithSpreadforASP.NETunderthefolderfortheWebsite.Addthefollowingcodetotheweb.configfile.Forexample:
XML
...
IfyouaddFpChartandyouareusingintegratedmanagedpipelinemode,youmaywishtosetvalidateIntegratedModeConfigurationtofalseinweb.config.Forexample:
XML
...
// If you are using integrated managed pipeline mode,//set validateIntegratedModeConfiguration to false.
Adding a Component to a Web Site using Visual Studio 2010
Spread for ASP.NET Developer’s Guide 30
Copyright © GrapeCity, Inc. All rights reserved.
-
AddinganFpSpreadcomponenttoaWebForminVisualStudio2010involvesthefollowingstepsofaddingthecomponenttoaWebSite.YoucaneitheropenanexistingWebSiteorcreateanewone.
Spread,asachildcontrolofthepage,isaffectedbythestylesettingsonthatpage(similartoplacingatableonawebform,andsettingamasterCSSforeverythinginsidethepage).IfyoucreateadefaultwebapplicationwithVisualStudio2010orhigher,thedefaultmasterpagecontainsCSSstylesettings.Spread,onceplacedonthisdefaultpage,canbeaffectedbythestylesettingsandthelayoutmaychange.AvoidthefollowingHTMLtagstopreventthelayoutchange:TD,TH,TABLE,INPUT,andTEXTAREA.
Step1.StartVisualStudio2010.
Step2.CreateanewWebsite.
1. FromtheFilemenu,chooseNew,WebSite.2. IntheNewWebSitedialog,selectatemplate.Forexample,fromthelistofTemplates,chooseASP.NETWebSiteorASP.NETEmptyWebSite.
3. IntheWeblocationarea,selectHTTPfromthedrop-downbox,andtypealocationpath,suchashttp://localhost/SpWebTest01.Alternatively,youcouldusethedefaultlocationtypeasFileSystem,andthenspecifythecompletepath,butthisrequiressomeadditionalsetupofcopyingthefp_clientfolder.
4. ClickOK.IfyourprojectdoesnotdisplaytheSolutionExplorer,fromtheViewmenu,chooseSolutionExplorer.Ifyouusedanemptysite,youmaywishtoaddawebpagetotheproject(chooseAddNewItemafterright-clickingontheprojectnameintheSolutionExplorer).
IntheSolutionExplorer,right-clickontheformname,Default.aspx.Youcanrenameit.ChooseRenamefromthepop-upmenu,thentypethenewformname.
Step3.AddtheFpSpreadcomponenttothetoolbox.Thisonlyhastobedoneonce.
1. IftheToolboxisnotdisplayed,fromtheViewmenuchooseToolbox.2. OncetheToolboxisdisplayed,lookintheGrapeCitySpreadcategory(orinothercategoriesifyouhave
installedSpreadandplacedthetoolboxiconinadifferentcategory).3. IftheFpSpreadcomponentisnotintheToolbox,right-clickintheToolbox,andfromthepop-upmenuchooseCustomizeToolbox,Add/RemoveItems,orChooseItems.
4. IntheCustomizeToolboxdialog,clickthe.NETFrameworkComponentstab.5. Inthe.NETFrameworkComponentstab,theFpSpreadcomponentshouldbedisplayedinthelistofcomponents.SelecttheFpSpreadcomponentcheckboxandclickOK.IftheFpSpreadcomponentisnotdisplayedinthelistofcomponents,clickBrowseandbrowsetotheinstallationpathfortheSpreadcomponent.Oncethere,selectSpreadWeb.dllandclickOpen.TheFpSpreadcomponentisnowdisplayedinthelistofcomponents.SelectitandclickOK.
6. Youcantestthatthecomponenthasbeenaddedbyopeningaprojectandinsertingthecomponent.
Step4.AddtheFpSpreadcomponenttotheWebsite.
1. Withanopenproject,intheToolboxunderWebForms,selecttheFpSpreadcomponent.2. OnyourWebFormspage,drawanFpSpreadcomponentbydraggingarectanglethesizethatyouwouldlikethe
initialcomponentorsimplydoubleclickonthepage.3. TheFpSpreadcomponentappears(asshowninthisVisualStudio2010project).
Spread for ASP.NET Developer’s Guide 31
Copyright © GrapeCity, Inc. All rights reserved.
-
Step5.HandlemessageswhenrunningtheWebsite.
1. WhenyouarereadytobuildandruntheWebsite,VisualStudiopopsupanadditionaldialogtoallowyoutochoosebetweenwhethertoenabledebuggingornottoenableit.Anexampleofthedialogappearshere.ClickOK,unlessyouwanttoselecttheotheroptiontorunwithoutdebuggingbeforeclickingOK.
Spread for ASP.NET Developer’s Guide 32
Copyright © GrapeCity, Inc. All rights reserved.
-
IfyouselecttheFileSystemforthelocation,followtheseadditionalinstructions.
Placethefp_clientfolder(installedinSpread.NET\ASP.NET\..\fp_client)anditssubfoldersprovidedwithSpreadforASP.NETunderthefolderfortheWebsite.Addthefollowingcodetotheweb.configfile.Forexample:
XML
...
Adding and Using JavaScript IntelliSense
TheSpreadcomponentcansupportclient-sidecodeIntelliSense.ThisrequiresaminimumofVisualStudio2010.Thisfeatureallowsyoutotypethenameofthecontrolandgetalistofavailablemethodsandproperties.Somebrowsersmaynotsupportcertainpropertiesandmethods.
Aftersupporthasbeenadded,typethecontrolnamefollowedbyadottoseethelist.
ThefollowingtopicscontaindetailedinformationbasedontheversionofVisualStudio:
AddingJavaScriptIntelliSenseforVisualStudio2012
AddingJavaScriptIntelliSenseforVisualStudio2010
Adding JavaScript IntelliSense for Visual Studio 2012
TheSpreadcomponentcansupportclient-sidecodeIntelliSenseinVisualStudio2012.Thisfeatureallowsyoutotypethenameofthecontrolandgetalistofavailablemethodsandproperties.Somebrowsersmaynotsupportcertainpropertiesandmethods.
Spread for ASP.NET Developer’s Guide 33
Copyright © GrapeCity, Inc. All rights reserved.
-
Aftersupporthasbeenadded,typethecontrolnamefollowedbyadottoseethelist.
ThisfeaturesrequirestheFpSpreadJsIntellisense.jsfilelocatedinthefp_clientfolder.Usethefollowingsteps:
1. Verifythatthe~/Scripts/_references.jsreferenceexistsinyourIntelliSensesettings.SelecttheOptionsmenuundertheToolsmenutoseethisdialog.ClickOK.
2. AddtheFpSpreadJsIntellisense.jsfiletothesamefolderwherethe_references.jsfileislocated.YoumayneedtocreateaScriptsfolderinyourprojectifthefolderdoesnotexist.Youmayalsoneedtocreatethe_references.jsfileundertheScriptsfolderifthefiledoesnotalreadyexist.
3. Addthefollowinglineto_references.js:///
4. OpenandclosetheFpSpreadJsIntellisense.jsfile.5. Spreadclient-sidemethodsandpropertiesshouldnowbedisplayedwhenyoutypethecontrolnamefollowedbyadot.
Spread for ASP.NET Developer’s Guide 34
Copyright © GrapeCity, Inc. All rights reserved.
-
Adding JavaScript IntelliSense for Visual Studio 2010
TheSpreadcomponentcansupportclient-sidecodeIntelliSense.ThisrequiresaminimumofVisualStudio2010.Thisfeatureallowsyoutotypethenameofthecontrolandgetalistofavailablemethodsandproperties.Somebrowsersmaynotsupportcertainpropertiesandmethods.
Aftersupporthasbeenadded,typethecontrolnamefollowedbyadottoseethelist.
AddingSupportforIntelliSense
ThisfeaturesrequirestheFpSpreadJsIntellisense.jsfilelocatedinthefp_clientfolder.Usethefollowingsteps:
CreateafoldernamedClientResourcesandputthefolderintheprojectfolder(orrootpathoftheapplicationorwebsite).PuttheFpSpreadJsIntelliSense.jsfileintheClientResourcesfolder.Addthefollowingcode(afterthetitle)totheaspxpage:
Code
function SomeFunction() {var spread = FpSpread("FpSpread1");// This variable declaration is necessary for the autocomplete.// Type spread. here to see the autocomplete.}
Thefinalaspxpagemightappearasfollows:
CodeUntitled Page
Spread for ASP.NET Developer’s Guide 35
Copyright © GrapeCity, Inc. All rights reserved.
-
window.onload = function () {var ss = document.getElementById("");if (document.all) {// IEif (ss.addEventListener) {// IE9ss.addEventListener("DataChanged", DataChanged, false);} else {// Other versions of IE and IE9 quirks mode (no doctype set)ss.onDataChanged = DataChanged;}}else {// Firefoxss.addEventListener("DataChanged", DataChanged, false);}}
function DataChanged(event) {var spread = FpSpread("FpSpread1");> // TYPE spread. here to see the auto-complete.}
The
blockwillevaluatetofalseatruntimesincethiscodeisonlyusedforcodeautocomplete.
Client-sideautocompletesupportcanalsobeusedinastand-alonejsfilewiththefollowingcode(thislinemustbebeforeanyscript):
Code
Understanding Browser Support
TheSpreadcomponentresidesontheserverandgeneratesHTMLpageswhenitisaccessedbyendusersontheclientside.TheappearanceandamountofinteractivityoftheWebpagedependsonthebrowserusedontheclientside.TheviewoftheHTMLpagesgeneratedbytheSpreadcomponentdependsonthebrowserbeingusedtoviewthepage.ThecomponentalsodownloadssomeHTMLcomponent(HTC)filestotheclientside.Thistopicsummarizessomebrowser-specificbehaviorsoftheproduct.Theseaspectsofbrowsersupport,discussedbelow,include:
BrowserLevel
TheappearanceandamountofinteractivityoftheWebpagedependsonthelevelofbrowser.Broadly,anuplevelbrowserisonethatcansupportclient-sideJavaScript,HTMLversion4.0,theMicrosoftDocumentObjectModel,andcascadingstylesheets(CSS).Adownlevelbrowserisonethatdoesnot.Foramoredetaileddefinitionofuplevelanddownlevelbrowserandforalistofcapabilitiesofthosebrowsers,refertothebrowsercapabilityinformationintheMicrosoft.NETdocumentation.
MozillaFirefoxSupport
WhilemostfeaturesworkinMozillaFirefox,notalldo.AllfeaturesworkinthelatestversionofMicrosoftInternetExplorer(IE).HereisalistoffeaturesthatarenotsupportedinFirefox.
Scrollbarproperties(seeCustomizingtheScrollBarColors)
Spread for ASP.NET Developer’s Guide 36
Copyright © GrapeCity, Inc. All rights reserved.
-
Forotheraffects,seethediscussionontheDOCTYPEAffectonRendering.
AppleSafariSupport
WhilemostfeaturesworkinAppleSafari,notalldo.Hereisalistoffeaturesthatarenotsupported.
Frozenrowsandcolumns(FrozenRowCount('FrozenRowCountProperty'intheon-linedocumentation)propertyandFrozenColumnCount('FrozenColumnCountProperty'intheon-linedocumentation)property)ImeModeforeditablecelltypesUIVirtualization('UIVirtualizationProperty'intheon-linedocumentation)property
AppleSafariSupportwithIPad
Hereisalistoffeaturesthatarenotsupported.
Panningmodeisnotsupported.Customtoolbarabovethesystemkeyboardisnotsupported.Scrollbarsarenotdisplayed.
GoogleChrome
Hereisalistoffeaturesthatarenotsupported.
ImeModeforeditablecelltypesScrollbarproperties(seeCustomizingtheScrollBarColors)
Client-SideScripting
Forotherbrowsers,besidesMicrosoftInternetExplorer(IE)andMozillaFirefox,theSpreadclient-sidescriptingisnotsupported.
Inyourscriptingcode,youwillneedtocheckthebrowsertoseeifitisFirefoxorIEbeforecallingthiscode,soyoucancallitcorrectlybasedonthebrowserthatisviewingthepage.Client-sidescriptingfortheFirefoxbrowserisalittledifferentthanitisforIE.YouneedtouseFirefox'swaytoattachevents.Forexample
Code
...
window.onload = function () { var spread1 = document.getElementById(""); if (document.all) { // IE if (spread1.addEventListener) { // IE9 spread1.addEventListener("DataChanged", dataChanged, false); } else { // Other versions of IE and IE9 quirks mode (no doctype set) spread1.onDataChanged = dataChanged; } } else { // Firefox spread1.addEventListener("DataChanged", dataChanged, false); } }
Spread for ASP.NET Developer’s Guide 37
Copyright © GrapeCity, Inc. All rights reserved.
-
function dataChanged() { alert("The data has changed!"); }
FirefoxdoesnotsupportJavaScriptpropertiesasIEdoes;everythingisaccessedwithmethods.Forexample,togettheactiverowandactivecolumn,youusetheGetActiveRow(on-linedocumentation)methodandtheGetActiveCol(on-linedocumentation)methodrespectively.Incode,
Codevar row = ss.GetActiveRow(); alert(row);
Forbrowser-levelissuesspecifictocertainmembers,refertothese:
FpSpread.EnableClientScript('EnableClientScriptProperty'intheon-linedocumentation)PropertySheetView.MessageRowStyle('MessageRowStyleProperty'intheon-linedocumentation)PropertySheetSkin.SelectionForeColor('SelectionForeColorProperty'intheon-linedocumentation)Property
andrefertoUnderstandingEffectsofClient-SideValidation.
AJAXSupport
SpreadforASP.NETsupportsAJAXinMicrosoftInternetExplorer(IE)andMozillaFirefoxbrowsers.
DOCTYPEAffectonRendering
TheDOCTYPEsettingscanaffecttherenderingofSpread.Considerthefollowing:
ColumnwidthsslightlydifferfromwhatyouseeinSpreadDesigner(IEandFirefox).SpreadinsideaDIVelementdoesnotscrollasexpected(IEandFirefox)Rowheightexpandstoshowthewrappingtext(IEandFirefox)
ThecolumnwidthsmayappearnarrowerinFirefoxthaninIE.Thishastodowiththedocumenttype(DOCTYPE)oftheHTMLpage.InIE,withcompliantmode,youwillseecolumnwidthswithmarginssettobelargerthatwhatyousetthemto.IfyouchangetheDOCTYPEofthepagetoTransitionalorremovethemarginsforthecells,youshouldseethesamecolumnwidthsusingeitherbrowser.Formoreinformation,refertotheIsStrictModemethod.
Note:SpreadrequiresthattheXMLnamespacebedeclaredasfollows:
SpreadusesHTMLtablesforthedisplayontheclientside.Whenyoudefinearowspan,itdefinesthespanfortheHTMLtableinthepage.ThedefaultbehaviorinInternetExplorerforaspannedrowinanHTMLtableistoresizetofitthetext.InSpread,therowisresizedtoavoidlayoutissues.Thereislittledocumentationoutliningthisbehavior,butyoucantestthisbehaviorinFirefoxwhereyoudonotseethecellresizeitselftodisplaythefulltext.However,itdoesnotforcethehorizontalscrollbartoremain.
Understanding Parts of the Component Interface
ThegeneratedSpreadcomponentinterfaceismadeupofthetoolbars(whichcanappearaboveandbelowthespreadsheet)andthesheetthatdisplaysthedata.Thefigurebelowshowsthemajorpartsofthecomponentinterface
Spread for ASP.NET Developer’s Guide 38
Copyright © GrapeCity, Inc. All rights reserved.
http://www.w3.org/1999/xhtml
-
thatcanbecustomized.
MoreinformationaboutthecomponentisavailableinCustomizingtheAppearanceoftheOverallComponentandCustomizingInteractionwiththeOverallComponent.
Thecommandbar,theoptionalpagenavigationbar,andthescrollbarsaredescribedinmoredetailinCustomizingtheToolBars.
Therowandcolumnheaders,consideredpartofthesheet,aredescribedinmoredetailinCustomizingtheAppearanceofHeaders.
Formoreinformationonthedataarea,includingthesheet,therowsandcolumns,andthecells,refertoCustomizingtheAppearanceoftheSheet,CustomizingtheAppearanceofRowsandColumns,andCustomizingtheAppearanceofaCell.
Working with Collection Editors
SeveralpropertiesthatappearinthePropertieswindowareassociatedwithcollections.Toviewandmodifythesesettings,clickontheBrowsebutton(...)andaseparateCollectionEditorwindowappears.ThisisthecasefortheNamedStyles('NamedStylesProperty'intheon-linedocumentation)propertyandtheSheets('SheetsProperty'intheon-linedocumentation)propertyintheFpSpreadcomponent.
Withthesecollectioneditors,youmustclickOKtoseetheresultsofachangetoasetting.(ThecollectioneditorsarepartoftheMicrosoft.NETframeworkanddonothaveanApplybutton.)
Spread for ASP.NET Developer’s Guide 39
Copyright © GrapeCity, Inc. All rights reserved.
-
Working with Web Parts
YoucanallowSpreadforASP.NETworkasaWebPartinaMicrosoftSharePointenvironment.Todoso,followthesesteps:
1. Setthetrustleveltofull.SettheTrustLevelinSharePointweb.configtoFull.2. MarktheSpreadDLLssafeinweb.config(FarPoint.CalcEngine.dll,FarPoint.Excel.dlland
FarPoint.Web.Spread.dll).
ThisassumesyouareusingthelatestversionofSharePoint(WSSorMOSS).ForearlierversionsofSharePointyoualsohadtheadditionalstepofexcludingthefp_clientfolderfromtheSharePointserver.Thisisnolongernecessary.
SpreadcanbeusedinsidetheWebPartyouaredeveloping.
Inearlierversionsoftheproduct,theFpSpread.RenderWebPartmethodwasusedforthe.NETFramework1.xwhenyoucreatedaWebPartbasedonMicrosoft.SharePoint.WebPartPages.WebPartclass.In.NETFramework2.x,theWebPartbecomespartoftheframework.IfyouusetheframeworkWebPartclass,System.Web.UI.WebControls.WebParts.WebPart,theFpSpread.RenderWebPartmethodisnolongerneeded.
SeeagoodintroductiontoWebPartsat:
https://msdn.microsoft.com/en-us/library/ee231579.aspx
Working with Windows Azure
YoucanuseSpreadforASP.NETinaWindowsAzureproject.Usethefollowingsteps:
1. Copythefp_clientfoldertoyourWebRoleprojectfolder.2. Includethisfp_clientfolderinyourWebRoleprojectandaddthefollowingsettingtotheweb.configfile.
Code
Youdonotneedtoeditweb.configifyouusethedevelopmentfabricinVisualStudio.
YoucanalsousetheChartcontrolinaWindowsAzureproject.YouwouldneedtoaddtheChartImageHttpHandlertothewebserversectionoftheweb.configfile.Ifyouareusingintegratedmanagedpipelinemode,setvalidateIntegratedModeConfigurationtoFalse.Forexample:
Code
...
Working with Microsoft ASP.NET MVC 5
YoucanuseSpreadforASP.NETinanMVC5project.MVCsupportinSpreadforASP.NETrequiresMicrosoftASP.NETMVC5,MicrosoftVisualStudio2013with.NET4.0Framework,andtheMicrosoftADO.NETEntity4.1Framework.
TheRazorviewgenerallyuses@infrontofthenameandtheASPXviewgenerallyusesaroundthename.UsethefollowingstepstocreateaprojectwithSpread:
Spread for ASP.NET Developer’s Guide 40
Copyright © GrapeCity, Inc. All rights reserved.
https://msdn.microsoft.com/en-us/library/ee231579.aspx
-
1. ReferenceFarPoint.Mvc.Spread.dllandFarPoint.Web.Spread.dllintheproject.2. AddtheSpreadinformationtotheLicenses.licxfile:
CodeFarPoint.Web.Spread.FpSpread, FarPoint.Web.Spread, Version=10.40.20162.0, Culture=neutral, PublicKeyToken=327c3516b1b18457FarPoint.Mvc.Spread.FpSpread, FarPoint.Mvc.Spread, Version=10.40.20162.0, Culture=neutral, PublicKeyToken=327c3516b1b18457
3. OpenGlobal.asax.cs,gototheApplication_Startfunctionandaddthefollowingregistrationcode:
IfyouuseSpreadMVCon.NETFramework4.0orabove,removeFarPoint.Mvc.Spread.MvcSpreadVirtualPathProvider.AppInitialize();fromApplication_Start().
C#protected void Application_Start(){//FarPoint.Mvc.Spread.MvcSpreadVirtualPathProvider.AppInitialize();AreaRegistration.RegisterAllAreas();RegisterGlobalFilters(GlobalFilters.Filters);RegisterRoutes(RouteTable.Routes);//ModelBinders.Binders.DefaultBinder = ModelBinders.Binders[typeof(FarPoint.Mvc.Spread.FpSpread)];//ModelBinders.Binders.Add(typeof(FarPoint.Mvc.Spread.FpSpread), new FarPoint.Mvc.Spread.MvcSpreadModelBinder());}
4. DeclareSpreadwiththeMVCSpreadnamespace:
Code@using FarPoint.Mvc.Spread; or
ThisallowsyoutohaveanMVCSpreadwiththefollowingcode:
[email protected]("FpSpread1"); or
FpSpread1istheSpreadID.Itshouldbeunique.
5. ProvideaccesstoMVCSpreadfromtheController.Whentheuserpostsbackdatatotheserver,thedevelopercanaccessthedeclaredMVCSpreadasanargument(theSpreadhasfullViewStateandnewpostbackdata).Forexample:
C#public ActionResult Index([FarPoint.Mvc.Spread.MvcSpread]FarPoint.Mvc.Spread.FpSpread FpSpread1){ViewBag.Message = "Welcome to GrapeCity";if (FpSpread1 != null){var value = FpSpread1.ActiveSheetView.Cells[0, 0].Value;}return View();}
Spread for ASP.NET Developer’s Guide 41
Copyright © GrapeCity, Inc. All rights reserved.
-
Ifyoudonotwanttouseanattribute,opentheGlobal.asax.csanduncommentoneofthelinesinstep3.
MakesuretheSpreadIDisthesameintheviewcodeandinthecontrolleractionparameter.
6. AttachSpreadevents:SpreadsupportsattachingeventsfromtheControlleronly.IfthereisanAJAXpostback,theSpreadeventswillnotbehandled.MvcSpreadallowsattaching3mainevents:Init,Load,andPreRender.Eventscanbegroupedorungrouped.Useoneofthefollowingmethodstohandletheevent:
Createafunctionwithaspecialname.
Thespecialnameindicatesthat“IwanttobindthisfunctiontoaSpreadevent”.Forexample,toattachtotheLoadeventofFpSpread1,thefunctionlookslikethefollowing:
C#public void FpSpread1_Load(object sender, EventArgs e){}Use MvcSpreadEventAttribute.In some cases, you may want to reserve a special name (like “FpSpread1_Load”). This can only be done by using the second method: MvcSpreadEventAttribute. The event handler can be shared globally or in a group.This example handles the Init event for all FpSpreads with the ID of FpSpread1 in any view, globally:[FarPoint.Mvc.Spread.MvcSpreadEvent("Init", "FpSpread1")]private void _init(object sender, EventArgs e){}
ThissolutionalsoprovidestheabilitytobindonefunctiontomanydifferentSpreads.ThefollowingexamplehandlestheIniteventforallFpSpreadswiththeIDofFpSpread1orFpSpread2inanyview,globally:
C#[FarPoint.Mvc.Spread.MvcSpreadEvent("Init", new string[] {"FpSpread1", "FpSpread2"})]private void _init(object sender, EventArgs e){}
Thesecondsolutionrequiresthatyouindicateimplicitlythatthefunction(withspecialname)shouldnotbeattachedautomatically:
C#[FarPoint.Mvc.Spread.NoMvcSpreadEvent]private void FpSpread1_Init(object sender, EventArgs e){}
ByattachingtotheInitorLoadevent,youcanattachtoothercustomSpreadeventssuchasTopRowChange,UpdateCommand,andsoon.
Additionalinformationaboutglobal,grouped,andungroupedevents:
AttachingeventswithagroupedMvcSpread:
IftheMvcSpreadisgrouped,useagroupname.Forexample:
C#// groupName is "GroupName" -> grouped
Spread for ASP.NET Developer’s Guide 42
Copyright © GrapeCity, Inc. All rights reserved.
-
public ActionResult Index([MvcSpread("GroupName", false)] FpSpread FpSpread1)// no groupName specified -> not groupedpublic ActionResult Index([MvcSpread(false)] FpSpread FpSpread1)
Thefollowingexamplesshowhowtohandlegroupevents:
C#// method Func3() is used to handle the Load event for all FpSpreads with ID of FpSpread1 in any view, inside the group called "GroupName"[MvcSpreadEvent("Load", "GroupName", "FpSpread1")]private void Func3(object sender, EventArgs e){}// method Func4() is used to handle the Load event for all FpSpreads with ID of FpSpread1, or FpSpread2 in any view, inside the group called "GroupName"[MvcSpreadEvent("Load", "GroupName", new string[] { "FpSpread1", "FpSpread2" })]private void Func4(object sender, EventArgs e){}
Anyfunctionnamed“[SpreadID]_[EventName]”istreatedasaglobaleventhandler.Theeventnameisindicatedby[EventName]andonlyanMvcSpreadwithanIDthesameas[SpreadID]canhandlethiseventhandler:
C#// this is a global handler for all FpSpread1 Load eventspublic void FpSpread1_Load(object sender, EventArgs e){}
Youcanexcludesomegroups(thatcontainFpSpreadcontrolsthatarenothandledbythismethod)fromglobaleventhandlers.Thesegroupscanbereferencedbytheirnames.Forexample:
C#// method abc() is used to handle the Load event for all FpSpread1 controls, excluding the ones that belong to GroupName1 or GroupName2[MvcSpreadEvent("Load", "FpSpread1")][MvcSpreadEventExclude("GroupName1", "GroupName2")]public void abc(object sender, EventArgs e){}// this method is used to handle the Load event for all FpSpread1 controls, excluding the ones that belong to GroupName1 or GroupName2[MvcSpreadEventExclude("GroupName1", "GroupName2")]public void FpSpread1_Load(object sender, EventArgs e){}
DeveloperdoesnotdeclareMvcSpreadinsidecontroller:
TheMvcSpreadisungroupediftheMvcSpreadisdeclaredinsidetheview.UsingagroupnamewithMvcSpreadintheviewmaycauseissuessincethereisacasewherethegroupnameinthecontrollerandthegroupnameintheviewaredifferent.IfMvcSpreadisnotdeclaredinthecontroller,theeventsareattachedtoglobaleventhandlersonly.
DeveloperdeclaresMvcSpreadinsidecontroller:
Iftheeventhandlersareglobal(groupnamenotdeclaredinMvcSpreadEventAttribute),theyattachtoallSpread
Spread for ASP.NET Developer’s Guide 43
Copyright © GrapeCity, Inc. All rights reserved.
-
controlswhethergroupedornot.
Iftheeventhandlersareprivate(groupnameexplicitlydeclaredinMvcSpreadEventAttribute),theyattachonlytoSpreadcontrolswiththesamegroupname.
Spreadcontrolswithoutagroupnameareattachedbyglobaleventhandlers.
Iftherearetwoeventhandlersforthesameevent,thefirstoneisprivateandthesecondoneisglobal.
ThecurrentSpreadlooksfortheglobaleventhandlerfirstwhenbindingevents.Iffound,bindingforthecurrenteventhappensfirst.Theprivateonewiththesamegroupnamehappensnext.
Note:UsingthecreateparametertonotifyMvcSpreadModelBindertocreateanewinstanceofMvcSpreadthefirsttimedoesnotaffectattachingevents.AneventhandlerisattachedtoMvcSpreadiftheeventIDlistcontainstheMvcSpreadID,regardlessofwhethertheeventhandlerisprivateorglobal.
7. PassMVCSpreadfromControllertoView:IfaninstanceofFpSpreadiscreatedbyamodel,itisappliedtotheviewautomatically.ThecodethatrendersFpSpreadwiththesameID,rendersthecurrentFpSpreadtotheclientbrowser:
C#public ActionResult Index([MvcSpread(true)] FpSpread FpSpread1){FpSpread1.ActiveSheetView.Rows.Count = 30;return View();}
IntheparameterlistIndex()actiontheFpSpread1isdeclaredspecificallyas[MvcSpread(true)]FpSpreadFpSpread1.Whenrunningthiscode,anewinstanceofFpSpreadiscreatedbyourModelBinder.TheActiveSheetView.Rows.Countissetto30,andthenthisinstanceisappliedtotheviewautomatically.TheFpSpreadcontrolwiththeIDof"FpSpread1"intheviewreceivesthesechanges.
Working with Microsoft ASP.NET MVC 3
YoucanuseSpreadforASP.NETinanMVC3project.MVCsupportinSpreadforASP.NETrequiresMicrosoftASP.NETMVC3,MicrosoftVisualStudio2010with.NET4.0Framework,andtheMicrosoftADO.NETEntity4.1Framework.
TheRazorviewgenerallyuses@infrontofthenameandtheASPXviewgenerallyusesaroundthename.UsethefollowingstepstocreateaprojectwithSpread:
1. ReferenceFarPoint.Mvc.Spread.dllandFarPoint.Web.Spread.dllintheproject.2. AddtheSpreadinformationtotheLicenses.licxfile:
CodeFarPoint.Web.Spread.FpSpread, FarPoint.Web.Spread, Version=8.40.20143.0, Culture=neutral, PublicKeyToken=327c3516b1b18457FarPoint.Mvc.Spread.FpSpread, FarPoint.Mvc.Spread, Version=8.40.20143.0, Culture=neutral, PublicKeyToken=327c3516b1b18457
3. OpenGlobal.asax.cs,gototheApplication_Startfunctionandaddthefollowingregistrationcode:
C#protected void Application_Start(){FarPoint.Mvc.Spread.MvcSpreadVirtualPathProvider.AppInitialize();AreaRegistration.RegisterAllAreas();RegisterGlobalFilters(GlobalFilters.Filters);RegisterRoutes(RouteTable.Routes);//ModelBinders.Binders.DefaultBinder =
Spread for ASP.NET Developer’s Guide 44
Copyright © GrapeCity, Inc. All rights reserved.
-
ModelBinders.Binders[typeof(FarPoint.Mvc.Spread.FpSpread)];//ModelBinders.Binders.Add(typeof(FarPoint.Mvc.Spread.FpSpread), new FarPoint.Mvc.Spread.MvcSpreadModelBinder());}
4. DeclareSpreadwiththeMVCSpreadnamespace:
Code@using FarPoint.Mvc.Spread; or
ThisallowsyoutohaveanMVCSpreadwiththefollowingcode:
[email protected]("FpSpread1"); or
FpSpread1istheSpreadID.Itshouldbeunique.
5. ProvideaccesstoMVCSpreadfromtheController.Whentheuserpostsbackdatatotheserver,thedevelopercanaccessthedeclaredMVCSpreadasanargument(theSpreadhasfullViewStateandnewpostbackdata).Forexample:
C#public ActionResult Index([FarPoint.Mvc.Spread.MvcSpread]FarPoint.Mvc.Spread.FpSpread FpSpread1){ViewBag.Message = "Welcome to GrapeCity";if (FpSpread1 != null){var value = FpSpread1.ActiveSheetView.Cells[0, 0].Value;}return View();}
Ifyoudonotwanttouseanattribute,opentheGlobal.asax.csanduncommentoneofthelinesinstep3.
MakesuretheSpreadIDisthesameintheviewcodeandinthecontrolleractionparameter.
6. AttachSpreadevents:SpreadsupportsattachingeventsfromtheControlleronly.IfthereisanAJAXpostback,theSpreadeventswillnotbehandled.MvcSpreadallowsattaching3mainevents:Init,Load,andPreRender.Eventscanbegroupedorungrouped.Useoneofthefollowingmethodstohandletheevent:
Createafunctionwithaspecialname.
Thespecialnameindicatesthat“IwanttobindthisfunctiontoaSpreadevent”.Forexample,toattachtotheLoadeventofFpSpread1,thefunctionlookslikethefollowing:
C#public void FpSpread1_Load(object sender, EventArgs e){}Use MvcSpreadEventAttribute.
In some cases, you may want to reserve a special name (like “FpSpread1_Load”). This can only be done by using the second method: MvcSpreadEventAttribute. The event handler can be shared globally or in a group.This example handles the Init event for all FpSpreads with the ID of FpSpread1 in any view, globally:
Spread for ASP.NET Developer’s Guide 45
Copyright © GrapeCity, Inc. All rights reserved.
-
[FarPoint.Mvc.Spread.MvcSpreadEvent("Init", "FpSpread1")]private void _init(object sender, EventArgs e){}
ThissolutionalsoprovidestheabilitytobindonefunctiontomanydifferentSpreads.ThefollowingexamplehandlestheIniteventforallFpSpreadswiththeIDofFpSpread1orFpSpread2inanyview,globally:
C#[FarPoint.Mvc.Spread.MvcSpreadEvent("Init", new string[] {"FpSpread1", "FpSpread2"})]private void _init(object sender, EventArgs e){}
Thesecondsolutionrequiresthatyouindicateimplicitlythatthefunction(withspecialname)shouldnotbeattachedautomatically:
C#[FarPoint.Mvc.Spread.NoMvcSpreadEvent]private void FpSpread1_Init(object sender, EventArgs e){}
ByattachingtotheInitorLoadevent,youcanattachtoothercustomSpreadeventssuchasTopRowChange,UpdateCommand,andsoon.
Additionalinformationaboutglobal,grouped,andungroupedevents:
AttachingeventswithagroupedMvcSpread:
IftheMvcSpreadisgrouped,useagroupname.Forexample:
C#// groupName is "GroupName" -> groupedpublic ActionResult Index([MvcSpread("GroupName", false)] FpSpread FpSpread1)// no groupName specified -> not groupedpublic ActionResult Index([MvcSpread(false)] FpSpread FpSpread1)
Thefollowingexamplesshowhowtohandlegroupevents:
C#// method Func3() is used to handle the Load event for all FpSpreads with ID of FpSpread1 in any view, inside the group called "GroupName"[MvcSpreadEvent("Load", "GroupName", "FpSpread1")]private void Func3(object sender, EventArgs e){}// method Func4() is used to handle the Load event for all FpSpreads with ID of FpSpread1, or FpSpread2 in any view, inside the group called "GroupName"[MvcSpreadEvent("Load", "GroupName", new string[] { "FpSpread1", "FpSpread2" })]private void Func4(object sender, EventArgs e){}
Anyfunctionnamed“[SpreadID]_[EventName]”istreatedasaglobaleventhandler.Theeventnameisindicatedby[EventName]andonlyanMvcSpreadwithanIDthesameas[SpreadID]canhandlethisevent
Spread for ASP.NET Developer’s Guide 46
Copyright © GrapeCity, Inc. All rights reserved.
-
handler:
C#// this is a global handler for all FpSpread1 Load eventspublic void FpSpread1_Load(object sender, EventArgs e){}
Youcanexcludesomegroups(thatcontainFpSpreadcontrolsthatarenothandledbythismethod)fromglobaleventhandlers.Thesegroupscanbereferencedbytheirnames.Forexample:
C#// method abc() is used to handle the Load event for all FpSpread1 controls, excluding the ones that belong to GroupName1 or GroupName2[MvcSpreadEvent("Load", "FpSpread1")][MvcSpreadEventExclude("GroupName1", "GroupName2")]public void abc(object sender, EventArgs e){}// this method is used to handle the Load event for all FpSpread1 controls, excluding the ones that belong to GroupName1 or GroupName2[MvcSpreadEventExclude("GroupName1", "GroupName2")]public void FpSpread1_Load(object sender, EventArgs e){}
DeveloperdoesnotdeclareMvcSpreadinsidecontroller:
TheMvcSpreadisungroupediftheMvcSpreadisdeclaredinsidetheview.UsingagroupnamewithMvcSpreadintheviewmaycauseissuessincethereisacasewherethegroupnameinthecontrollerandthegroupnameintheviewaredifferent.IfMvcSpreadisnotdeclaredinthecontroller,theeventsareattachedtoglobaleventhandlersonly.
DeveloperdeclaresMvcSpreadinsidecontroller:
Iftheeventhandlersareglobal(groupnamenotdeclaredinMvcSpreadEventAttribute),theyattachtoallSpreadcontrolswhethergroupedornot.
Iftheeventhandlersareprivate(groupnameexplicitlydeclaredinMvcSpreadEventAttribute),theyattachonlytoSpreadcontrolswiththesamegroupname.
Spreadcontrolswithoutagroupnameareattachedbyglobaleventhandlers.
Iftherearetwoeventhandlersforthesameevent,thefirstoneisprivateandthesecondoneisglobal.
ThecurrentSpreadlooksfortheglobaleventhandlerfirstwhenbindingevents.Iffound,bindingforthecurrenteventhappensfirst.Theprivateonewiththesamegroupnamehappensnext.
Note:UsingthecreateparametertonotifyMvcSpreadModelBindertocreateanewinstanceofMvcSpreadthefirsttimedoesnotaffectattachingevents.AneventhandlerisattachedtoMvcSpreadiftheeventIDlistcontainstheMvcSpreadID,regardlessofwhethertheeventhandlerisprivateorglobal.
7. PassMVCSpreadfromControllertoView:IfaninstanceofFpSpreadiscreatedbyamodel,itisappliedtotheviewautomatically.ThecodethatrendersFpSpreadwiththesameID,rendersthecurrentFpSpreadtotheclientbrowser:
C#public ActionResult Index([MvcSpread(true)] FpSpread FpSpread1){FpSpread1.ActiveSheetView.Rows.Count = 30;
Spread for ASP.NET Developer’s Guide 47
Copyright © GrapeCity, Inc. All rights reserved.
-
return View();}
IntheparameterlistIndex()actiontheFpSpread1isdeclaredspecificallyas[MvcSpread(true)]FpSpreadFpSpread1.Whenrunningthiscode,anewinstanceofFpSpreadiscreatedbyourModelBinder.TheActiveSheetView.Rows.Countissetto30,andthenthisinstanceisappliedtotheviewautomatically.TheFpSpreadcontrolwiththeIDof"FpSpread1"intheviewreceivesthesechanges.
Copying Shared Assemblies to Local Folder
FarPoint.CalcEngine.dll,FarPoint.Excel.dll,andFarPoint.PDF.dllareinstalledtotheGACbydefaultwheninstallingSpreadforASP.NET.
Youcanusethesmarttagverb"CopySharedAssembliesLocal"tocopyFarPoint.CalcEngine.dll,FarPoint.Excel.dll,andFarPoint.PDF.dlltothelocalbinfolderonthewebsitewhendeploying.
Thesmarttagverbappearsasfollows:
Thefollowingentryisaddedtotheweb.configfile:
Code
Spread for ASP.NET Developer’s Guide 48
Copyright © GrapeCity, Inc. All rights reserved.
-
Working with Strongly Typed Data Controls
Strong-typeddatacontrolssupportbindingusinganewsyntaxthatisavailableinASP.NET4.5.Thisallowsyoutodirectlyreferencepropertiesonthedatasourceobjectinthemarkup.Forexample,inordertobinddatatoPreviewRowTemplateandRowEditTemplatebeforeASP.NET4.5,codetobindtotheFirstNamepropertyonyourdatasourceitemlookedlikethis:
Code
First Name is: First Name is:
WithASP.NET4.5youcanusecodelikethefollowing:
Code
First Name is: First Name is:
UsingcodeinyourmarkupthiswayallowsyoutogettheaddedbenefitsofIntelliSenselistingofyourdatasourceobject'spropertiesandvalidationofthepropertynameatdesigntime.
Getting More Practice
Herearethetasksforgettingmorepracticewiththeproduct.
UnderstandingProceduresintheDocumentationGettingTechnicalSupport(on-linedocumentation)
Understanding Procedures in the Documentation
ThereareseveraldifferentwaystoaccomplishthesameresultwhencreatingaWindowsFormspagewithaSpreadcomponent.Inthisdocumentation,theproceduresoftendescribemorethanoneway,includingusingtheProperties
Spread for ASP.NET Developer’s Guide 49
Copyright © GrapeCity, Inc. All rights reserved.
-
windowinVisualStudio.NET,writingcodeincludingusingshortcutobjects,andusingtheSpreadDesigner.TheSpreadDesignersetspropertiesandcallsmethodsforthecomponent,includingpropertiesnotavailableatdesigntimethroughVisualStudio.NET,withoutproducinganyeditablecode.
Eachofthesehasitsadvantagesanddisadvantages.Usingshortcutobjectsistheshortest,quickestwayofaddingcodeusingdotnotationandsettingapropertyofashortcutobject.Usingcodewithoutusingshortcutobjectsgenerallymeansdeclaringobjectsandsettingpropertiesforthem.Typically,foreitherwayofwritingcode,thereisanexamplegiven.
DocumentationProvided
TheSpreadforASP.NETdocumentationprovidesintroductoryinformationabouttheproduct,conceptualinformation,how-totopics,andadetailedassemblyandformulafunctionreferenceinahelpfileandinPDFfiles.AdditionalinformationisprovidedintheReadmefile.
AccessingtheHelp
YoucanaccessthehelpthroughF1supportprovidedinVisualStudio.NET.Whilethecomponentoroneofitsmembershasfocus,pressF1todisplaytheSpreadforASP.NEThelp.
Youcanalsoaccessthehelpfileinastand-alonewindowbychoosingStart‑>Programs‑>GrapeCity‑>...->Product->Help.
DocumentationConventions
TheformatofthehelpissimilartothehelpprovidedforVisualStudio.NET.Referencematerialformembersprovidesmultiplelanguagereferenceforthemember.Youcanchangewhichlanguage'ssyntaxisdisplayedbyclickingtheLanguagesbuttoninthetitleofthetopic.
ListofHow-To's
Hereisalistofthecommonlyusedprocedurescoveredinthedocumentation:
AddingaNotetoaCellAddingaRoworColumnAddingaSheetApplyingaSkintoaSheetCustomizingtheDimensionsoftheComponentCustomizingtheNumberofRowsorColumnsCreatingaCustomFunctionCreatingaCustomNameCreatingaSkinforSheetsCreatingAlternatingRowsCustomizingtheOutlineoftheComponentCustomizingtheSheetCornerDisplayingGridLinesontheSheetDisplayingScrollBarsLockingaCellNestingFunctionsinaFormulaOpeningExistingFilesPlacingaFormulainCellsRemovingaRoworColumnRemovingaSheetSavingDatatoaFile
Spread for ASP.NET Developer’s Guide 50
Copyright © GrapeCity, Inc. All rights reserved.
-
SettingtheBackgroundColoroftheSheetSettingtheRowHeightorColumnWidthSpecifyingaCellReferenceStyleinaFormulaUsingaCircularReferenceinaFormulaWorkingwithEditableCellTypesWorkingwithGraphicalCellTypes
Getting Technical Support
Ifyouhaveatechnicalquestionaboutthisproduct,consultthefollowingsources:
Helpandotherdocumentationfilesinstalledwiththeproduct.Forinstructionsforaccessingthehelpandotherdocumentationfiles,seeUnderstandingProceduresintheDocumentation.
Productforumathttps://www.grapecity.com/en/forums#spread
Ifyoucannotfindtheanswerusingthesesources,pleasecontactTechnicalSupportusingoneofthesemethods:
Website: https://www.grapecity.com/en/forums
E-mail: [email protected]
Fax: (412)681-4384
Phone: (412)681-4738
TechnicalSupportisavailablebetweenthehoursof9:00a.m.and5:30p.m.Easterntime,MondaythroughFriday.
Understanding the Spread Wizard
YoucanusetheSpreadWizardtoquicklyandeasilybinddata,setupthecolumnstructure,andcustomizetheappearanceofaspreadsheet.Seethefollowingtopicsformoreinformation:
StartingtheSpreadWizardUsingtheSpreadWizard
Starting the Spread Wizard
YoucanlaunchtheSpreadWizardfromtheSmartTagsontheFpSpreadcomponentontheWebForminVisualStudioasshowninthisfigure.
Spread for ASP.NET Developer’s Guide 51
Copyright © GrapeCity, Inc. All rights reserved.
https://www.grapecity.com/en/forums#spreadhttps://www.grapecity.com/en/forumsmailto:[email protected]
-
Using the Spread Wizard
YoucanusetheSpreadWizardtobindtoadatasource,setcolumnproperties,settheoperationmode,specifytitles,selectasheetskin,andmanyothers.
Selectthemenuoptionofthefeatureyouwishtocustomize,locatedontheleftsideofthedialog.SelectthevariousoptionsforthatfeatureandthenclickNexttogotothenextstep.Whenyouarefinished,clickFinish.
Spread for ASP.NET Developer’s Guide 52
Copyright © GrapeCity, Inc. All rights reserved.
-
Tutorial: Creating a Checkbook Register
ThefollowingtutorialwalksyouthroughcreatinganASP.NETprojectinVisualStudio.NETusingtheSpreadforASP.NETcomponent.Bycreatingacheckbookregister,youwilllearnhowtomodifytheappearanceofaspreadsheet,workwithcelltypes,andaddsomeformulasforperformingcalculations.Inthistutorial,themajorstepsare
AddingSpreadtotheCheckbookProjectAddingSpreadtoaProjectSettingUptheRowsandColumnsoftheRegisterSettingtheCellTypesoftheRegisterAddingFormulastoCalculateBalances
Adding Spread to the Checkbook Project
StartanewVisualStudio.NETproject.Nametheprojectcheckbook.Nametheformintheprojectregister.aspx.AddtheFpSpreadcomponenttoyourproject,andthenplacethecomponentontheform.
IfyoudonotknowhowtoaddtheFpSpreadcomponenttotheproject,completethestepsinAddingSpreadtoaProject.
Spread for ASP.NET Developer’s Guide 53
Copyright © GrapeCity, Inc. All rights reserved.
-
Adding Spread to a Project
ThisandallthetutorialsassumethatyouhaveVisualStudio.NETinstalledonyoursystem,andInternetInformationServices(IIS)installedandrunningonyoursystemasthelocalhostserver.
PerformthestepsinthistutorialtosetupanASP.NETVisualStudio.NETprojectthatcontainstheSpreadforASP.NETcomponent.
1. StartVisualStudio.NET.2. FromtheFilemenu,chooseNew,Project.3. IntheNewProjectdialog,4. IntheProjectTypeslist,chooseeitherVisualBasicProjectsorVisualC#Projectsdependingonthe
languageyouareusing.5. IntheTemplateslist,chooseASP.NETWebApplication.6. IntheLocationbox,leavethelocationpathashttp://localhost/unlessyouprefertosavethisprojecttoanother
server.ChangetheprojectnamefromWebApplication1tothenameofyourchoice.7. ClickOK.8. IntheSolutionExplorer,right-clickontheformname,WebForm1.aspx.ChooseRenamefromthepop-up
menu,thentypethenewformnameyoupreferforthenewformname.9. IfyourprojectdoesnotdisplaytheSolutionExplorer,fromtheViewmenu,chooseSolutionExplorer.10. IftheToolboxisnotdisplayed,fromtheViewmenuchooseToolbox.11. IntheToolbox,lookintheWebFormscategory(orinothercategoriesifyouhaveinstalledSpreadandplaced
thetoolboxiconinadifferentcategory).IftheSpreadcomponentisnotintheToolbox,performsteps12through14.Otherwise,proceedtostep15.
12. Right-clickintheToolbox,andfromthepop-upmenuchooseCustomizeToolbox.13. IntheCustomizeToolboxdialog,clickthe.NETFrameworkComponentstab.14. Inthe.NETFrameworkComponentstab,
a. ClickBrowse.b. BrowsetotheinstallationpathfortheSpreadforASP.NETcomponent.Oncethere,select
FarPoint.Web.Spread.dllandclickOpen.c. TheFpSpreadcomponentisnowdisplayedinthelistofcomponents.ClickOK.
15. IntheToolboxunderWebFormsoranothertab,selecttheFpSpreadcomponent.16. Onyourform,drawanFpSpreadcomponent.17. Saveyourproject.
Yourprojectshouldnowlooksimilartothefollowingimage:
Spread for ASP.NET Developer’s Guide 54
Copyright © GrapeCity, Inc. All rights reserved.
-
YouhaveaddedtheSpreadcomponenttotheproject.
Setting Up the Rows and Columns of the Register
TheSpreadcomponentonyourformalreadyhasasheet,readyforyoutoconfigure.Inthisstep,youaregoingtosetupthecolumnsandcellsinthesheettoresembleacheckbookregister.
1. Double-clickontheforminyourprojecttoopenthecodewindow.2. Selectthelineofcode
C#// Put user code to initialize the page here.
VB'Put user code to initialize the page here.
andtypethefollowingcodetoreplaceit:
C#if (this.IsPostBack) return;// Set up component and rows and columns in sheet.FpSpread1.Height = Unit.Pixel(300);FpSpread1.Width = Unit.Pixel(763);FpSpread1.Sheets[0].ColumnCount = 8;
Spread for ASP.NET Developer’s Guide 55
Copyright © GrapeCity, Inc. All rights reserved.
-
FpSpread1.Sheets[0].RowCount = 100;
VBIf (IsPostBack) ThenReturnEnd If' Set up component and rows and columns in sheet.FpSpread1.Height = Unit.Pixel(300)FpSpread1.Width = Unit.Pixel(763)FpSpread1.Sheets(0).ColumnCount = 8FpSpread1.Sheets(0).RowCount = 100
Thiscodesetsupthecomponenttobe300pixelshighand763pixelswide,andthesheettohave8columnsand100rows.
3. Nowweneedtosetupthecolumnstohavecustomheadings.AddthefollowingcodebelowthecodeyouaddedinStep2:
C#// Add text to column heading.FpSpread1.ColumnHeader.Cells[0, 0].Text = "Check #";FpSpread1.ColumnHeader.Cells[0, 1].Text = "Date";FpSpread1.ColumnHeader.Cells[0, 2].Text = "Description";FpSpread1.ColumnHeader.Cells[0, 3].Text = "Tax?";FpSpread1.ColumnHeader.Cells[0, 4].Text = "Cleared?";FpSpread1.ColumnHeader.Cells[0, 5].Text = "Debit";FpSpread1.ColumnHeader.Cells[0, 6].Text = "Credit";FpSpread1.ColumnHeader.Cells[0, 7].Text = "Balance";
VB' Add text to column heading.FpSpread1.ColumnHeader.Cells(0, 0).Text = "Check #"FpSpread1.ColumnHeader.Cells(0, 1).Text = "Date"FpSpread1.ColumnHeader.Cells(0, 2).Text = "Description"FpSpread1.ColumnHeader.Cells(0, 3).Text = "Tax?"FpSpread1.ColumnHeader.Cells(0, 4).Text = "Cleared?"FpSpread1.ColumnHeader.Cells(0, 5).Text = "Debit"FpSpread1.ColumnHeader.Cells(0, 6).Text = "Credit"FpSpread1.ColumnHeader.Cells(0, 7).Text = "Balance"
4. Nowsetupthecolumnwidthstoproperlydisplayourheadingsandthedatayouwilladd.AddthefollowingcodebelowthecodeyouaddedinStep3:
C#// Set column widths.FpSpread1.Sheets[0].Columns[0].Width = 50;FpSpread1.Sheets[0].Columns[1].Width = 50;FpSpread1.Sheets[0].Columns[2].Width = 200;FpSpread1.Sheets[0].Columns[3].Width = 40;FpSpread1.Sheets[0].Columns[4].Width = 65;FpSpread1.Sheets[0].Columns[5].Width = 100;FpSpread1.Sheets[0].Columns[6].Width = 100;FpSpread1.Sheets[0].Columns[7].Width = 125;
VB
Spread for ASP.NET Developer’s Guide 56
Copyright © GrapeCity, Inc. All rights reserved.
-
' Set column widths.FpSpread1.Sheets(0).Columns(0).Width = 50FpSpread1.Sheets(0).Columns(1).Width = 50FpSpread1.Sheets(0).Columns(2).Width = 200FpSpread1.Sheets(0).Columns(3).Width = 40FpSpread1.Sheets(0).Columns(4).Width = 65FpSpread1.Sheets(0).Columns(5).Width = 100FpSpread1.Sheets(0).Columns(6).Width = 100FpSpread1.Sheets(0).Columns(7).Width = 125
5. Saveyourproject,thenfromtheDebugmenuchooseStarttorunyourproject.
YourASP.NETpageshouldlooksimilartothefollowingpicture.
Setting the Cell Types of the Register
Tosetcelltypes,foreachcustomcelltype,youhavetocreateacelltypeobject,setthepropertiesforit,andthenassignthatobjecttotheCellType('CellTypeProperty'intheon-linedocumentation)propertyforacellorrangeofcells.
1. SetthecelltypefortheCheck#columnbyaddingthefollowingcodebelowthecodeyouhavealreadyadded:
C#// Create Check # column of integer cells.FarPoint.Web.Spread.IntegerCellType objIntCell = new FarPoint.Web.Spread.IntegerCellType();FpSpread1.Sheets[0].Columns[0].CellType = objIntCell;
VB' Create Check # column of integer cells.Dim objIntCell As New FarPoint.Web.Spread.IntegerCellType()FpSpread1.Sheets(0).Columns(0).CellType = objIntCell
2. SetthecelltypefortheDatecolumnbyaddingthefollowingcodebelowthecodeyouhavealreadyadded:
C#// Create Date column of date-time cells.
Spread for ASP.NET Developer’s Guide 57
Copyright © GrapeCity, Inc. All rights reserved.
-
FarPoint.Web.Spread.DateTimeCellType objDateCell = new FarPoint.Web.Spread.DateTimeCellType();objDateCell.FormatString = "M/dd/yyyy";FpSpread1.Sheets[0].Columns[1].CellType = objDateCell;
VB' Create Date column of date-time cells.Dim objDateCell As New FarPoint.Web.Spread.DateTimeCellType()objDateCell.FormatString ="M/dd/yyyy"FpSpread1.Sheets(0).Columns(1).CellType = objDateCell
3. SetthecelltypefortheDescriptioncolumnbyaddingthefollowingcodebelowthecodeyouhavealreadyadded:
C#// Create Description column of general cells.FarPoint.Web.Spread.GeneralCellType objGenCell = new FarPoint.Web.Spread.GeneralCellType();FpSpread1.Sheets[0].Columns[2].CellType = objGenCell;
VB' Create Description column of general cells.Dim objGenCell As New FarPoint.Web.Spread.GeneralCellType()FpSpread1.Sheets(0).Columns(2).CellType = objGenCell
4. SetthecelltypefortheTax?andCleared?columnsbyaddingthefollowingcodebelowthecodeyouhavealreadyadded:
C#/// Create Tax? and Cleared? columns of check box cells.FarPoint.Web.Spread.CheckBoxCellType objCheckCell = new FarPoint.Web.Spread.CheckBoxCellType();FpSpread1.Sheets[0].Columns[3].CellType = objCheckCell;FpSpread1.Sheets[0].Columns[4].CellType = objCheckCell;
VB' Create Tax? and Cleared? columns of check box cells.Dim objCheckCell As New FarPoint.Web.Spread.CheckBoxCellType()FpSpread1.Sheets(0).Columns(3).CellType = objCheckCellFpSpread1.Sheets(0).Columns(4).CellType = objCheckCell
5. SetthecelltypefortheDebit,Credit,andBalancecolumnsbyaddingthefollowingcodebelowthecodeyouhavealreadyadded:
C#// Create the Debit, Credit, and Balance columns of currency cells.FarPoint.Web.Spread.CurrencyCellType objCurrCell = new FarPoint.Web.Spread.CurrencyCellType();FpSpread1.Sheets[0].Columns[5].CellType = objCurrCell;FpSpread1.Sheets[0].Columns[6].CellType = objCurrCell;FpSpread1.Sheets[0].Columns[7].CellType = objCurrCell;
VB' Create the Debit, Credit, and Balance columns of currency cells.Dim objCurrCell As New FarPoint.Web.Spread.CurrencyCellType()
Spread for ASP.NET Developer’s Guide 58
Copyright © GrapeCity, Inc. All rights reserved.
-
FpSpread1.Sheets(0).Columns(5).CellType = objCurrCellFpSpread1.Sheets(0).Columns(6).CellType = objCurrCellFpSpread1.Sheets(0).Columns(7).CellType = objCurrCell
6. Saveyourproject,thenfromtheDebugmenuchooseStarttorunyourproject.
YourASP.NETpageshouldlooksimilartothefollowingpicture.
Adding Formulas to Calculate Balances
Yourcheckbookregisterisnowsetuptolooklikeacheckbookregister;however,itdoesnotbalancethecurrencyfiguresyouenterintheregister.Thisstepsetsuptheformulaforbalancingthefigures.
1. Belowthecodeyouhavealreadyadded,addthefollowingcode:
C#// Set formula for calculating balance.FpSpread1.Sheets[0].ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1;FpSpread1.Sheets[0].Cells[0, 7].Formula = "RC[-1]-RC[-2]";for (int i = 1; i < 99; i++){ FpSpread1.Sheets[0].Cells[i, 7].Formula = "R[-1]C-RC[-2]+RC[-1]";}
VB' Set formula for calculating balance.FpSpread1.Sheets(0).ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1FpSpread1.Sheets(0).Cells(0, 7).Formula = "RC[-1]-RC[-2]"Dim i As IntegerFor i = 1 To 99 FpSpread1.Sheets(0).Cells(i, 7).Formula = "R[-1]C-RC[-2]+RC[-1]"Next
2. Saveyourproject,thenfromtheDebugmenuchooseStarttorunyourproject.
YourASP.NETpageshouldlooksimilartothefollowingpicture.Typedataintoyourcheckbookregistertotestitandsee
Spread for ASP.NET Developer’s Guide 59
Copyright © GrapeCity, Inc. All rights reserved.
-
howitoperates.ClickonthecheckmarkicontosavethechangesorsettheClientAutoCalculationpropertyforthecontroltoTrue.
Yourcheckbookregisteriscomplete!Youhavecompletedthistutorial.
Spread for ASP.NET Developer’s Guide 60
Copyright © GrapeCity, Inc. All rights reserved.
-
Understanding the Product
SpreadforASP.NETprovidesacompletelynew,object-orientedspreadsheetcomponentforuseintheMicrosoft.NETframework.Thefollowingtopicsprovideanintroductiontothisuniqueandpowerfulproductandexplainsomeoftheunderlyingconcepts.
ProductOverviewFeaturesOverviewConceptsOverviewNamespacesOverview
Product Overview
SpreadforASP.NETisacomprehensivespreadsheetcomponentforWebapplicationsthatcombinesgridcapabilities,spreadsheetfunctionality,andincludestheabilitytobindtodatasources.Asinglecomponentcancontainmanysheets,columns,androws.Cross-sheetreferencingallowscalculationstomakeuseofdataandformulasonavarietyofsheets.SpreadforASP.NETusesdotnotationforobject-orientedcoding