Tabelle e intervalli
Introduzione
A volte crei una tabella in Microsoft Excel e non vuoi continuare a lavorare con la funzionalità tabella che la accompagna. Invece, desideri qualcosa che assomigli a una tabella. Per mantenere i dati in una tabella senza perdere la formattazione, converti la tabella in un intervallo regolare di dati. Aspose.Cells supporta questa funzione di Microsoft Excel per tabelle e oggetti elenco.
Utilizzando Microsoft Excel
Utilizzare la funzionalità Converti in Intervallo per convertire rapidamente una tabella in un intervallo senza perdere la formattazione. In Microsoft Excel 2007/2010:
- Fare clic ovunque nella tabella per garantire che la cella attiva sia in una colonna della tabella.
- Sulla scheda Design, nel gruppo Strumenti, fare clic su Converti in intervallo.
Usare Aspose.Cells
Il seguente snippet di codice dimostra la stessa funzionalità utilizzando Aspose.Cells.
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
Aspose::Cells::Startup(); | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
// Instantiate a Workbook object and open an Excel file | |
Workbook workbook(dirPath + u"sample.xlsx"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.GetWorksheets().Get(0); | |
// Get the List objects collection in the first worksheet. | |
ListObjectCollection listObjects = worksheet.GetListObjects(); | |
// Convert the first table/list object (from the first worksheet) to normal range | |
listObjects.Get(0).ConvertToRange(); | |
// Saving the Excel file | |
workbook.Save(outPath + u"ConvertTableToRange_out.xls"); | |
Aspose::Cells::Cleanup(); |