Quick Start
Introduction
This guide shows how to create a workbook, write typed cell values, apply number formatting, and save the result to an .xlsx file using Aspose.Cells FOSS for Java.
Create a Workbook in 5 Minutes
After installing the Maven dependency, the following example creates a workbook with one named sheet, writes a text header and a numeric value, applies bold formatting and a custom number format to the value, sets row height and column width, and saves the workbook:
import com.aspose.cells_foss.Cell;
import com.aspose.cells_foss.Style;
import com.aspose.cells_foss.Workbook;
import com.aspose.cells_foss.Worksheet;
public class QuickStart {
public static void main(String[] args) {
try (Workbook workbook = new Workbook()) {
WorksheetCollection sheets = workbook.getWorksheets();
Worksheet sheet = sheets.get(0);
sheet.setName("Report");
sheet.getCells().get("A1").putValue("Revenue");
Cell b1 = sheet.getCells().get("B1");
b1.putValue(12500.75);
Style style = b1.getStyle();
style.getFont().setBold(true);
style.setCustom("#,##0.00");
b1.setStyle(style);
sheet.getCells().getRows().get(0).setHeight(22.0);
sheet.getCells().getColumns().get(1).setWidth(14.5);
workbook.save("report.xlsx");
System.out.println("report.xlsx created.");
}
}
}Next Steps
- Developer Guide — explore features
- API Reference — browse the full API