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("提示:创建成功!");

            }

  • 相关阅读:
    Python全栈开发之21、django
    Python全栈开发之17、tornado和web基础知识
    Python全栈开发之18、cookies、session和ajax等相关知识
    jquery之别踩白块游戏的实现
    Python全栈开发之16、jquery
    Python全栈开发之15、DOM
    Python全栈开发之13、CSS
    Python全栈开发之12、html
    Go语言学习之路-2-变量与常量
    Go语言学习之路-1-Go语言环境搭建
  • 原文地址:https://www.cnblogs.com/cppfans140812/p/5694417.html
Copyright © 2011-2022 走看看