NPOI读取模板并且生成新模板

 
sender, EventArgs e)
    {


        FileStream file = new FileStream(Server.MapPath("template/") + "a.xls", FileMode.Open, FileAccess.Read); 
        HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
        file.Close();
        ISheet sheet1 = hssfworkbook.GetSheet("Sheet1");

        if (sheet1.GetRow(23) == null)
        {
            sheet1.CreateRow(23);
        }
        if (sheet1.GetRow(23).GetCell(6) == null)
        {
            sheet1.GetRow(23).CreateCell(6);
        }

        sheet1.GetRow(23).GetCell(6).SetCellValue(300); 

        sheet1.ForceFormulaRecalculation = true;
        FileStream file2 = new FileStream(Server.MapPath("template/") + "ccc.xls", FileMode.Create, FileAccess.Write); 
        hssfworkbook.Write(file2); 
        file2.Close();

    }

你可能感兴趣的:(ASP.NET,C#)