You can print a single sheet or all the sheets in SpreadJS.
The following content is printed when you print in SpreadJS:
The following information is not printed:
Use the print method to print a sheet or sheets. Use an index to specify a specific sheet or no index for all visible sheets. You can specify many print options with the PrintInfo class such as whether to print headers, borders, grid lines, and so on.
The following table displays the options that can be used when creating a print header or footer:
Control Character | Description | Example | Result |
& | Escape character | ||
P | Current page | sheet.printInfo().headerLeft("This is page &P of &N pages."); |
This is page 1 of 10 pages. (If there are 10 pages and this is first page.) |
N | Page count | sheet.printInfo().headerLeft("This is page &P of &N pages."); |
This is page 1 of 10 pages. (If there are 10 pages and this is first page.) |
D | Current date | sheet.printInfo().headerLeft("It is &D."); |
It is 2015/6/19. (If today is June 19, 2015.) |
T | Current time | sheet.printInfo().headerLeft( "It is &T." |
It is 16:30:36. (If 16:30:36 is now.) |
G | Image | var printInfo = new GC.Spread.Sheets.Print.PrintInfo(); |
Displays an image. |
S | Strikethrough | sheet.printInfo().headerLeft("&SThis is text."); |
|
U | Underline | sheet.printInfo().headerLeft("&UThis is text."); |
This is text. |
B | Bold | sheet.printInfo().headerLeft("&BThis is text."); |
This is text. |
I | Italic | sheet.printInfo().headerLeft("&IThis is text."); |
This is text. |
" | Font prefix | sheet.printInfo().headerLeft("&\"Lucida Console\"This is text."); |
This is text. |
K | Color prefix | sheet.printInfo().headerLeft("&KFF0000This is text."); |
This is text. |
F | Spread name | sheet.printInfo().headerLeft("spead name: &F"); |
spread name: testSpread (If printed spread's name is "testSpread".) |
A | Sheet name | sheet.printInfo().headerLeft("sheet name: &A"); |
sheet name: Sheet1 (If printed sheet's name is "Sheet1".) |
The orientation method is only supported when importing or exporting to Excel. The paperSize method only applies to the paging result, not the printer. Print preview is not supported. The printing result may be different between browsers.
Note: Printing requires that you add the printing module to the page (gc.spread.sheets.print.*.*.*.min.js).
This example prints a sheet.
JavaScript |
Copy Code
|
---|---|
<script src="./scripts/pluggable/gc.spread.sheets.print.12.0.0.min.js" type="application/javascript"></script> ... var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3}); // Set the value |