//Specify the file path String filePath = myDir + "Book1.xlsx"; //Specify the HTML Saving Options HtmlSaveOptions save = new HtmlSaveOptions(SaveFormat.HTML); //Instantiate a workbook and open the template XLSX file Workbook book = new Workbook(filePath); //Save the HTML file book.save(myDir + "output.html", save);
//Instantiate a new workbook with excel file path Workbook workbook = new Workbook("F:\\FileTemp\\Book1.xls"); //Save the document in Pdf format workbook.save("F:\\FileTemp\\MyPdfFile.pdf", FileFormatType.PDF);
//Instantiate a new workbook with excel file path Workbook workbook = new Workbook("F:\\FileTemp\\Book1.xls"); //Save the document in Pdf format workbook.save("F:\\FileTemp\\MyPdfFile.pdf", FileFormatType.PDF);
//Instantiate a new workbook with excel file path Workbook workbook = new Workbook("F:\\FileTemp\\Book1.xls"); //Save the document in Pdf format workbook.save("F:\\FileTemp\\MyPdfFile.pdf", FileFormatType.PDF);
int headerRows = 3; Workbook workerBook = new Workbook(); Worksheet workSheet = workerBook.getWorksheets().get(0); //style.setTextWrapped(true); Cell workSheetCell = workSheet.getCells().get("A1"); workSheet.getCells().merge(3, 0, headerRows, 1); workSheet.getCells().merge(3, 1, headerRows, 1); workSheet.getCells().merge(3, 2, headerRows, 1); // workSheet.getCells().get("C4").putValue("Time"); workSheet.getCells().get("A4").putValue("Respondent"); workSheet.getCells().get("B4").putValue("Date"); workSheet.getCells().get("C4").putValue("Time"); workerBook.save("SettingData.xlsx"); workerBook.save("myoutputSettingData.xml", SaveFormat.SPREADSHEET_ML);
cellC4.setStyle(style); workerBook.save("output.xlsx", SaveFormat.XLSX);
Workbook workerBook = new Workbook(); Worksheet worksheet = workerBook.getWorksheets().get(0); //Display word "Date" in cell B4 Cell cellB4 = worksheet.getCells().get("B4"); cellB4.putValue("Date"); //Display word "Time" in cell C4 Cell cellC4 = worksheet.getCells().get("C4"); cellC4.putValue("Time"); //Save the workbook in xlsx format workerBook.save("output.xlsx", SaveFormat.XLSX);
//Suppose your person id is 7, so your data will be inserted in row 7 int personId = 7; //Suppose that person's data is 5, then it will be inserted in column E (A, B, C, D, E, F, G...) int personData = 5; Workbook workbook = new Workbook(); Worksheet worksheet = workbook.getWorksheets().get(0); String cellName = CellsHelper.cellIndexToName(personId - 1, personData - 1); worksheet.getCells().get(cellName).putValue(personData); workbook.save("output.xlsx", SaveFormat.XLSX);
int headerRows = 3; Workbook workerBook = new Workbook(); Worksheet workSheet = workerBook.getWorksheets().get(0); //style.setTextWrapped(true); Cell workSheetCell = workSheet.getCells().get("A1"); workSheet.getCells().merge(3, 0, headerRows, 1); workSheet.getCells().merge(3, 1, headerRows, 1); workSheet.getCells().merge(3, 2, headerRows, 1); // workSheet.getCells().get("C4").putValue("Time"); workSheet.getCells().get("A4").putValue("Respondent"); workSheet.getCells().get("B4").putValue("Date"); workSheet.getCells().get("C4").putValue("Time"); workerBook.save(DIR + "SettingData.xltx", SaveFormat.XLTX);
//Open the first excel file. Workbook SourceBook1 = new Workbook("F:\\Downloads\\charts.xlsx"); //Define the second source book. //Open the second excel file. Workbook SourceBook2 = new Workbook("F:\\Downloads\\picture.xlsx"); //Combining the two workbooks SourceBook1.combine(SourceBook2); //Save the target book file. SourceBook1.save("F:\\Downloads\\combined.xlsx");
line3.setPlacement(PlacementType.FREE_FLOATING); oWorkbook.save("C:\\test3.xlsx");
workbook.save(Common.DATA_DIR + "cellstyle.xlsx");
workbook.save(excelFile.replace(".xlsx", sheetCounter + ".xlsx"));
//Instantiating a Workbook object Workbook workbook = new Workbook(); //Accessing the added worksheet in the Excel file int sheetIndex = workbook.getWorksheets().add(); Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); Cells cells = worksheet.getCells(); Column column = cells.getColumns().get(30); Style style1 = column.getStyle(); style1.setHorizontalAlignment(TextAlignmentType.CENTER); style1.setCustom("$#,##0;[Red]$-#,##0"); StyleFlag styleFlag1 = new StyleFlag(); styleFlag1.setNumberFormat(true); styleFlag1.setHorizontalAlignment(true); //Applying the style to the column column.applyStyle(style1, styleFlag1); //Saving the modified Excel file in default format workbook.save("C:\\output.xls");
workbook.save("c:\\HtmlStringtest.xlsx");
book.save(dataDir + "protectedrange.xlsx");