0
我與Apache POI工作創造新的專欄,我有一個問題,如使用的兩列分裂添加新列,也希望以百分比來獲得(%)使用單元格公式的Apache POI
請求的輸出
這裏是Java代碼,
public class ApacheCreatePivotTab
{
public static void main(String[] args) throws Exception
{
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
//Create some data to build the pivot table on
setCellData(sheet);
FileOutputStream fileOut = new FileOutputStream("output.xlsx");
wb.write(fileOut);
fileOut.close();
wb.close();
}
public static void setCellData(XSSFSheet sheet)
{
Row row1 = sheet.createRow(0);
// Create a cell and put a value in it.
Cell cell11 = row1.createCell(0);
cell11.setCellValue("Names");
Cell cell12 = row1.createCell(1);
cell12.setCellValue("utilization_pct");
Row row2 = sheet.createRow(1);
// Create a cell and put a value in it.
Cell cell21 = row2.createCell(0);
cell21.setCellValue("Michal");
Cell cell22 = row2.createCell(1);
cell22.setCellValue("6772.00902935");
Row row3 = sheet.createRow(2);
// Create a cell and put a value in it.
Cell cell31 = row3.createCell(0);
cell31.setCellValue("Michal");
Cell cell32 = row3.createCell(1);
cell32.setCellValue("6118.1434599");
Row row4 = sheet.createRow(3);
// Create a cell and put a value in it.
Cell cell41 = row4.createCell(0);
cell41.setCellValue("Michal");
Cell cell42 = row4.createCell(1);
cell42.setCellValue("5000");
Row row5 = sheet.createRow(4);
// Create a cell and put a value in it.
Cell cell51 = row5.createCell(0);
cell51.setCellValue("Michal");
Cell cell52 = row5.createCell(1);
cell52.setCellValue("5279.50310559");
Row row6 = sheet.createRow(5);
// Create a cell and put a value in it.
Cell cell61 = row6.createCell(0);
cell61.setCellValue("Henry");
Cell cell62 = row6.createCell(1);
cell62.setCellValue("6170.8860759");
}
}
此代碼給我我所進行的操作,將其添加第三列一個表
將其舍入爲2個十進制數。 –
謝謝,但我想首先在java中使用apache poi庫執行單元操作如何在java中執行此操作 –
要創建新列? –