zoukankan      html  css  js  c++  java
  • excel的模板

    这是一种npoi的  看见这个的时候发现不错,就留了下来 

     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();

    下面这一种是本人自己写的一个epplus关于模板的,不说废话直接上代码

    string str = Application.StartupPath + "\readiness form_0427.xlsx";
    FileStream fs = new FileStream(str, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
    ExcelPackage ep = new ExcelPackage(fs);
    ExcelWorksheet sheet = ep.Workbook.Worksheets[1];
    sheet.Cells[1, 11].Value = "纬度";
    sheet.Cells[10, 11].Value = "纬度";
    fs.Close();
    string sr=AppDomain.CurrentDomain.BaseDirectory + @"output eadiness";
    if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"output"))
    {
    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"output");
    }
    fs = new FileStream(str, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
    ep.SaveAs(fs);//存档
    fs.Close();
    ep.Dispose();
    ep = null;

  • 相关阅读:
    ipad 横屏 竖屏 CSS
    播放多个音视频文件
    插入百度地图
    js getByClass函数封装
    jq 测试是否到页面最底端
    python字符串跟整型互转
    day01-day04总结- Python 数据类型及其用法
    斐波那契数列的非递归
    LeetCode: 3SumClosest
    LeetCode: 3Sum
  • 原文地址:https://www.cnblogs.com/xiaojian1/p/5465392.html
Copyright © 2011-2022 走看看