[]
This tutorial shows how to persist generated or modified Excel workbooks using Document Solutions for Excel, Java Edition (DsExcel Java). You’ll learn how to create a minimal workbook in memory and save it as a standard .xlsx file using the Workbook.save() method.
Before you begin, make sure you have:
JDK 8 or later
Document Solutions for Excel, Java Edition (DsExcel Java)
The DsExcel JARs added to your classpath
Import the required namespaces:
import com.grapecity.documents.excel.*;Start by creating a new Workbook object and getting the first worksheet:
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.setName("Sheet1");(Optional) Add a little data so you can verify output:
worksheet.getRange("A1").setValue("Hello from DsExcel Java!");
worksheet.getRange("A2").setValue(12345);To export the workbook, call Workbook.save() from your workbook object with a file name or full path.
workbook.save("output.xlsx");Be sure to replace "temp" with the file path to where you are trying to save the file.
workbook.save("C:\\temp\\output.xlsx");workbook.save("/tmp/output.xlsx");DsExcel Java is designed to run server-side and does not require Microsoft Excel or Office Interop.
Common server-side usage patterns include:
Generating Excel reports in a REST API
Updating uploaded .xlsx templates and exporting a final version
Running automated scheduled exports on Linux servers
Read the full documentation page here.
Explore a full demo showcasing this feature here.