@ Author YHC
Set the workbook zoom in ratio:
Set the workbook to zoom in with scores. In the following example, the ratio is adjusted to 75%, 3 is the numerator, and 4 is the denominator;
[Java]
// Create an Excel file
Workbook wb = new HSSFWorkbook ();
// Create a workbook
Sheet sheet1 = wb. createSheet ("new sheet ");
// Set the workbook to zoom in
Sheet1.setZoom (3, 4); // 75 percent magnification
//
// Write a file
FileOutputStream fileOut = new FileOutputStream ("workbook.xls ");
Wb. write (fileOut );
FileOut. close ();
// Create an Excel file
Workbook wb = new HSSFWorkbook ();
// Create a workbook
Sheet sheet1 = wb. createSheet ("new sheet ");
// Set the workbook to zoom in
Sheet1.setZoom (3, 4); // 75 percent magnification
//
// Write a file
FileOutputStream fileOut = new FileOutputStream ("workbook.xls ");
Wb. write (fileOut );
FileOut. close ();
:
Set the header and footer:
The following example sets the header, but can also be used to set the footer directly.
[Java]
// Create an Excel file
Workbook wb = new HSSFWorkbook ();
// Create a workbook
Sheet sheet = wb. createSheet ("new sheet ");
// Create a header
Header header = sheet. getHeader ();
// Customize the header and set the information displayed in the left-right corner of the header
Header. setCenter ("Center Header ");
Header. setLeft ("Left Header ");
Header. setRight (HSSFHeader. font ("stenpencil-Normal", "Italic") +
HSSFHeader. fontSize (short) 16) + "Right w/stencel-Normal Italic font and size 16 ");
// Write a file
FileOutputStream fileOut = new FileOutputStream ("workbook.xls ");
Wb. write (fileOut );
FileOut. close ();
// Create an Excel file
Workbook wb = new HSSFWorkbook ();
// Create a workbook
Sheet sheet = wb. createSheet ("new sheet ");
// Create a header
Header header = sheet. getHeader ();
// Customize the header and set the information displayed in the left-right corner of the header
Header. setCenter ("Center Header ");
Header. setLeft ("Left Header ");
Header. setRight (HSSFHeader. font ("stenpencil-Normal", "Italic") +
HSSFHeader. fontSize (short) 16) + "Right w/stencel-Normal Italic font and size 16 ");
// Write a file
FileOutputStream fileOut = new FileOutputStream ("workbook.xls ");
Wb. write (fileOut );
FileOut. close (); Note: After the code is run, it is a blank page. How can I check whether the setting is effective:
Open your Excel file-> page settings-> Tab to select the header and footer-> click custom header:
Author: yhc13429826359