Export to PDF"
From Documentation
(Created page with "__TOC__ = PDF Exporter = {{ZSS EE}} <!-- For http://tracker.zkoss.org/browse/ZSS-827, I just show standard Exporter usage instead of PdfExporter --> In addition to the Exce...") |
(add header, footer) |
||
Line 1: | Line 1: | ||
+ | {{ZKSpreadsheetEssentials3PageHeader}} | ||
+ | |||
+ | |||
__TOC__ | __TOC__ | ||
Line 114: | Line 117: | ||
** Down, then over | ** Down, then over | ||
** Over, then down | ** Over, then down | ||
+ | |||
+ | |||
+ | {{ZKSpreadsheetEssentialsPageFooter}} |
Revision as of 01:45, 17 November 2014
PDF Exporter
Available in ZK Spreadsheet EE only
In addition to the Excel format, you can also export a book model as a PDF file with Exporter
Example to export as a PDF
package org.zkoss.zss.essential;
import java.io.*;
import org.zkoss.util.media.AMedia;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.*;
import org.zkoss.zss.api.*;
import org.zkoss.zss.api.model.Book;
import org.zkoss.zss.ui.Spreadsheet;
import org.zkoss.zul.*;
public class ExportPdfComposer extends SelectorComposer<Component> {
@Wire
private Spreadsheet ss;
@Wire("combobox")
private Combobox combobox;
Exporter exporter = Exporters.getExporter("pdf");
@Listen("onClick = #exportPdf")
public void doExport() throws IOException{
Book book = ss.getBook();
File file = File.createTempFile(Long.toString(System.currentTimeMillis()),"temp");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
exporter.export(book, file);
}finally{
if(fos!=null){
fos.close();
}
}
Filedownload.save(new AMedia(book.getBookName()+".pdf", "pdf", "application/pdf", file, true));
}
//omit some code for brevity
}
Line 21: Get an Exporter instance for PDF format.
Load Excel Printing Setup
Since 3.6.0
Spreadsheet exports its book model to a PDF file according to the page print setup you specify in Excel.
For example you can add header and footer, and it would look like:
You can also scale a sheet to fit into one page with row and column heading:
Supported Page Setup
The page setup properties of Excel which are supported by Spreadsheet are listed below:
Page
- Orientation
- Portrait, Landscape
- Scaling
- Adjust to % normal size
- Fit to pages wide by tall
- Page size
- First page number
Margins
- Top
- Header
- Right
- Footer
- Bottom
- Left
Center on Page
- Horizontally
- Vertically
Header/Footer
- Custom Header...
- Custom Footer...
- Different odd and even pages
- Different first page
Sheet
- Print area
- Print titles
- Rows to repeat at top
- Columns to repeat at left
- Print
- Gridlines
- Row and column headings
- Page order
- Down, then over
- Over, then down
All source code listed in this book is at Github.