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

            }

  • 相关阅读:
    [HDU 2089]不要62
    [WC 2011]Xor
    [BJOI 2011]元素
    [NOIp 2014]解方程
    [UVa 1326]Jurassic Remains
    [BZOJ 2152]聪聪可可
    [IOI 2011]Race
    [测试题]打地鼠
    [POJ 2828]Buy Tickets
    [测试题]gene
  • 原文地址:https://www.cnblogs.com/cppfans140812/p/5694417.html
Copyright © 2011-2022 走看看