This section summarizes how DsExcel Java handles the import and export of Excel files containing templates (.xltx file).
DsExcel Java allows users to load and save spreadsheets containing templates without any hassles. Excel templates are pre-designed spreadsheets that help to create spreadsheets with the same layout, formatting, and formulas without having to recreate the basic elements each time, thereby saving significant amounts of time while working with spreadsheets. Now, users can load such spreadsheets in DsExcel directly as Xltx files, modify them easily and quickly, and then save them back.
DsExcel Java also provides various import and export options, which can be accessed from the properties present in XltxOpenOptions and XltxSaveOptions classes. For more information about import and export options provided by DsExcel, see Import and Export Excel Options.
When the OpenFileFormat is Xltx, templates will be imported. When the SaveFileFormat is Xltx, templates will be exported.
Refer to the following example code in order to import and export Xltx document from the file name:
Java |
Copy Code |
---|---|
// Create a new workbook. Workbook workbook = new Workbook(); // Open xltx file. workbook.open("excel-loan-calculator.xltx", OpenFileFormat.Xltx); // Save workbook as xltx file. workbook.save("Exported.xltx", SaveFileFormat.Xltx); |
Refer to the following example code in order to import and export Xltx document from a file stream:
Java |
Copy Code |
---|---|
// Create a new workbook. var streamworkbook = new Workbook(); // Create a new file stream to open a file. InputStream openFile; try { openFile = new FileInputStream("excel-loan-calculator.xltx"); // Open xltx file. streamworkbook.open(openFile, OpenFileFormat.Xltx); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Create a new file stream to save a file. OutputStream out; try { out = new FileOutputStream("Exported-Stream.xltx"); // Save workbook as xltx file. streamworkbook.save(out, SaveFileFormat.Xltx); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } |