Lägg till eller infoga ett arbetsblad
Contents
[
Hide
]
I det här ämnet kommer vi att diskutera teknikerna för att lägga till eller infoga kalkylblad i en Excel-fil med Aspose.Cells.GridDesktop. Skillnaden mellan att lägga till och infoga kalkylblad är att dessutom läggs ett kalkylblad helt enkelt till i slutet av kalkylbladssamlingen i Excel-filen, men infogning innebär att lägga till ett kalkylblad till en specifik position i kalkylbladssamlingen.
Lägga till ett arbetsblad
För att lägga till ett kalkylblad med Aspose.Cells.GridDesktop, följ stegen nedan:
- Lägg till Aspose.Cells.GridDesktop-kontroll i ett formulär.
- Anropa kalkylbladssamlingens Lägg till metod i GridDesktop-kontrollen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Adding a worksheet to the Grid | |
int i = gridDesktop1.Worksheets.Add(); | |
Worksheet sheet = gridDesktop1.Worksheets[i]; |
Många överbelastade versioner av Add-metoden finns tillgängliga. Med den ovan överbelastade versionen läggs till exempel ett kalkylblad till i Excel-filen med ett standardarknamn. Med andra överbelastade versioner av Add-metoden är det möjligt att definiera namnet som visas nedan i exemplet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Adding a worksheet to the Grid with a specific name | |
Worksheet sheet1 = gridDesktop1.Worksheets.Add("AddWorksheetWithName"); |
Infoga ett arbetsblad
För att infoga ett kalkylblad med Aspose.Cells.GridDesktop, följ stegen nedan:
- Lägg till Aspose.Cells.GridDesktop-kontrollen i ett formulär.
- Anropa Worksheets-samlingens Insert-metod i GridDesktop-kontrollen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Inserting a worksheet to Grid at first position of the worksheets collection | |
gridDesktop1.Worksheets.Insert(0); |
VIKTIGT: Microsoft Excel (97-2003 XLS) stöder Excel-ark med upp till 65 536 rader och 256 kolumner. Aspose.Cells.GridDesktop följer samma standarder. I Aspose.Cells.GridDesktop-kontrollen kan utvecklare lägga till eller infoga kalkylblad med fler rader och kolumner än standardgränsen, men när de försöker spara Grid-data till en Excel-fil kommer ett undantag att skapas. Det betyder att endast data som finns i de 65 536 raderna och 256 kolumnerna kan sparas i en Excel XLS-fil med Aspose.Cells.GridDesktop, om du använder XLSX (MS Excel 2007/2010) filformat finns det dock ingen sådan begränsning.