Adatta automaticamente riga e colonna

Come adattare automaticamente riga e colonna utilizzando Aspose.Cells for Java

L’approccio più semplice per ridimensionare automaticamente la larghezza e l’altezza di una riga consiste nel chiamare il metodo Worksheet.autoFitRow. Il metodo autoFitRow accetta come parametro un indice di riga (della riga da ridimensionare).

**Notare che:**Se desideri adattare automaticamente righe e colonne nei fogli di calcolo Excel utilizzando Java, visitaAdatta automaticamente righe e colonne.

Java

 Workbook workbook = new Workbook("workbook.xls");

//Accessing the first worksheet in the Excel file

Worksheet worksheet = workbook.getWorksheets().get(0);

worksheet.autoFitRow(1); //Auto-fitting the 2nd row of the worksheet

worksheet.autoFitColumn(0); //Auto-fitting the 1st column of the worksheet

//Saving the modified Excel file in default (that is Excel 2003) format

workbook.save("AutoFit_Aspose.xls");

Apache POI SS - HSSF XSSF - Adatta automaticamente riga e colonna

Apache POI SS - HSSF e XSSF forniscono Sheet.autoSizeColumn per adattare automaticamente le colonne

Java

 InputStream inStream = new FileInputStream("workbook.xls");

Workbook workbook = WorkbookFactory.create(inStream);

Sheet sheet = workbook.createSheet("new sheet");

sheet.autoSizeColumn(0); //adjust width of the first column

sheet.autoSizeColumn(1); //adjust width of the second column

FileOutputStream fileOut;

fileOut = new FileOutputStream("AutoFit_Apache.xls");

workbook.write(fileOut);

fileOut.close();

Scarica il codice in esecuzione

Scarica il codice di esempio