Convertire una tabella Excel in un intervallo di dati

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:

  1. Fare clic ovunque nella tabella per garantire che la cella attiva sia in una colonna della tabella.

todo:image_alt_text

  1. Sulla scheda Design, nel gruppo Strumenti, fare clic su Converti in intervallo.

todo:image_alt_text

Usare Aspose.Cells

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(ConvertTableToRange.class) + "tables/";
// Open an existing file that contains a table/list object in it
Workbook wb = new Workbook(dataDir + "book1.xlsx");
// Convert the first table/list object (from the first worksheet) to normal range
wb.getWorksheets().get(0).getListObjects().get(0).convertToRange();
// Save the file
wb.save(dataDir + "ConvertTableToRange_out.xlsx");

Converti Tabella in Intervallo con Opzioni

Aspose.Cells fornisce opzioni aggiuntive durante la conversione della Tabella in Intervallo tramite la classe TableToRangeOptions. La classe TableToRangeOptions fornisce la proprietà LastRow che consente di impostare l’ultimo indice della riga della tabella. La formattazione della tabella verrà mantenuta fino all’indice di riga specificato e il resto della formattazione verrà rimossa.

Il codice di esempio qui sotto dimostra l’uso della classe TableToRangeOptions.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(ConvertTableToRangeWithOptions.class) + "Tables/";
// Open an existing file that contains a table/list object in it
Workbook workbook = new Workbook(dataDir + "book1.xlsx");
TableToRangeOptions options = new TableToRangeOptions();
options.setLastRow(5);
// Convert the first table/list object (from the first worksheet) to normal range
workbook.getWorksheets().get(0).getListObjects().get(0).convertToRange(options);
// Save the file
workbook.save(dataDir + "ConvertTableToRangeWithOptions_out.xlsx");