I have a header which I need to set on every page that is printed on a dynamic excel sheet.
我有一个标题,我需要在动态Excel工作表上打印的每个页面上设置。
Is there any way to get the page number ?
有没有办法获得页码?
1 个解决方案
#1
2
As from swamy's comment the solution is to get the HSSFHeader
from the HSSFSheet
从swamy的评论来看,解决方案是从HSSFSheet获取HSSFHeader
HSSFHeader header = sheet.getHeader();
Then you can set left, center and right text including font, font style, font size, page number, date, time etc.
然后您可以设置左,中,右文本,包括字体,字体样式,字体大小,页码,日期,时间等。
Example
header.setCenter(HSSFHeader.font("Calibri", "regular") +
HSSFHeader.fontSize((short) 14) + "My " + HSSFHeader.startBold() + "Styled" +
HSSFHeader.endBold() + " Text with page number " + HSSFHeader.page());
Result
#1
2
As from swamy's comment the solution is to get the HSSFHeader
from the HSSFSheet
从swamy的评论来看,解决方案是从HSSFSheet获取HSSFHeader
HSSFHeader header = sheet.getHeader();
Then you can set left, center and right text including font, font style, font size, page number, date, time etc.
然后您可以设置左,中,右文本,包括字体,字体样式,字体大小,页码,日期,时间等。
Example
header.setCenter(HSSFHeader.font("Calibri", "regular") +
HSSFHeader.fontSize((short) 14) + "My " + HSSFHeader.startBold() + "Styled" +
HSSFHeader.endBold() + " Text with page number " + HSSFHeader.page());
Result