zoukankan      html  css  js  c++  java
  • npoi 添加 xls页眉页脚重复标题页码

    npoi 添加 xls页眉页脚重复标题页码

    private static void TestHyf()
            {
                IWorkbook book = new HSSFWorkbook();
                ISheet sheet = book.CreateSheet("test");
                ICellStyle cellStyle = book.CreateCellStyle();
                cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
                cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
                cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
                cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
                IRow row = sheet.CreateRow(0);
                for (int i = 0; i < 5; i++)
                {
                    ICell cell = row.CreateCell(i);
                    cell.SetCellValue("col" + i);
                }
                for (int i = 1; i < 10000; i++)
                {
                    IRow rowtemp = sheet.CreateRow(i);
                    for (int j = 0; j < 5; j++)
                    {
                        ICell cell = rowtemp.CreateCell(j);
                        cell.SetCellValue(i * j);
                        cell.CellStyle = cellStyle;
                    }
                }
                sheet.FitToPage = false;
                sheet.RepeatingRows = new CellRangeAddress(0, 0, 0, 5);
                sheet.Header.Center = "testtop";
                sheet.Footer.Center = "testfooter";
                sheet.Footer.Right="第 &P 页,共 &N 页";//&P当前页码&N总页码数
                using (FileStream fs = File.OpenWrite(@"c:/myxls.xls"))
                    book.Write(fs);
                MessageBox.Show("提示:创建成功!");

            }

  • 相关阅读:
    背景qwq
    关于Oracle数据库空表无法导出问题
    Linux 备份 Oracle11g 数据库
    Linux Tomcat安装
    Linux JDK安装
    Oracle 监听与服务器
    Xftp强制更新
    Linux 安装 Oracle11g 数据库
    Vue 动态获取组件与动态路由获取组件
    Linux 防火墙
  • 原文地址:https://www.cnblogs.com/cppfans140812/p/5694417.html
Copyright © 2011-2022 走看看