EasyExcel 设置打印的纸张为A3
时间: 2024-06-14 14:04:59 浏览: 204
easyexcel代码
5星 · 资源好评率100%
以下是使用EasyExcel设置打印纸张为A3的示例代码:
```java
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import org.apache.poi.ss.usermodel.PaperSize;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import java.awt.print.PrinterJob;
public class EasyExcelPrintA3Example {
public static void main(String[] args) {
// 创建工作簿
Workbook workbook = EasyExcel.write("output.xlsx").build().write().getWorkbook();
// 获取第一个工作表
Sheet sheet = workbook.getSheetAt(0);
// 设置纸张大小为A3
sheet.getPrintSetup().setPaperSize(PaperSize.A3);
// 其他操作,例如写入数据等
// 关闭工作簿
workbook.close();
}
}
```
阅读全文