Arbeitsmappe und tabellenblattumfassende benannte Bereiche erstellen
Microsoft Excel ermöglicht es Benutzern, benannte Bereiche mit zwei verschiedenen Bereichen zu definieren: arbeitsmappe (auch als globaler Bereich bekannt) und tabellenblatt.
- Benannte Bereiche mit arbeitsmappenbereich können von jedem Arbeitsblatt innerhalb dieser Arbeitsmappe aus durch einfaches Verwenden ihres Namens aufgerufen werden.
- Auf tabellenblattbeschränkte benannte Bereiche werden mithilfe des Verweises auf das bestimmte Arbeitsblatt, in dem sie erstellt wurden, aufgerufen.
Aspose.Cells bietet dieselbe Funktionalität wie Microsoft Excel zum Hinzufügen von arbeitsmappe- und tabellenblattumfassenden benannten Bereichen. Beim Erstellen eines tabellenblattumfassenden benannten Bereichs sollte der Verweis auf das tabellenblatt im benannten Bereich verwendet werden, um ihn als tabellenblattumfassenden benannten Bereich zu kennzeichnen.
Hinzufügen eines benannten Bereichs mit arbeitsmappenbereich
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create a new Workbook object | |
Workbook workbook = new Workbook(); | |
// Get first worksheet of the workbook | |
Worksheet sheet = workbook.Worksheets[0]; | |
// Get worksheet's cells collection | |
Cells cells = sheet.Cells; | |
// Create a range of Cells from Cell A1 to C10 | |
Range workbookScope = cells.CreateRange("A1", "C10"); | |
// Assign the nsame to workbook scope named range | |
workbookScope.Name = "workbookScope"; | |
// Save the workbook | |
workbook.Save(dataDir+ "WorkbookScope.out.xlsx"); |
Hinzufügen eines benannten Bereichs mit tabellenblattbereich
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create a new Workbook object | |
Workbook workbook = new Workbook(); | |
// Get first worksheet of the workbook | |
Worksheet sheet = workbook.Worksheets[0]; | |
// Get worksheet's cells collection | |
Cells cells = sheet.Cells; | |
// Create a range of Cells | |
Range localRange = cells.CreateRange("A1", "C10"); | |
// Assign name to range with sheet raference | |
localRange.Name = "Sheet1!local"; | |
// Save the workbook | |
workbook.Save(dataDir+ "ouput.out.xls"); |