Converti una tabella di Excel in un intervallo di dati

Utilizzando Microsoft Excel

Usa ilConverti in intervallo funzionalità per convertire rapidamente una tabella in un intervallo senza perdere la formattazione. In Microsoft Excel 2007/2010:

  1. Fare clic in un punto qualsiasi della tabella per assicurarsi che la cella attiva sia in una colonna della tabella.

cose da fare:immagine_alt_testo

  1. SulDesign scheda, nelUtensili gruppo, fare clicConverti in intervallo.

cose da fare:immagine_alt_testo

Utilizzando 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 le opzioni

Aspose.Cells fornisce opzioni aggiuntive durante la conversione della tabella in intervallo attraverso ilTableToRangeOptionsclasse. IlTableToRangeOptionsla classe fornisceUltima rigaproprietà 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à rimosso.

Il codice di esempio fornito di seguito dimostra l’uso diTableToRangeOptionsclasse.

// 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");