NOPI用模板生成excel
来源:互联网 发布:idea mac 激活服务器 编辑:程序博客网 时间:2024/06/05 20:18
private void btnCopy_Click(object sender, EventArgs e)
{
try
{
//Excel模板的路径
FileStream file = new FileStream(@"e:/book1.xls", FileMode.Open, FileAccess.Read);
HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
Sheet sheet1 = hssfworkbook.GetSheet("Sheet1");
//sheet1.CreateRow(3).CreateCell(3).SetCellValue(12345);
//string value1=sheet1.GetRow(1).GetCell(1).ToString();
//sheet1.GetRow(2).GetCell(1).SetCellValue(true);
//sheet1.GetRow(1).GetCell(1).SetCellValue("Chen");
//sheet1.GetRow(1).GetCell(1).SetCellValue("sss");
//sheet1.GetRow(1).GetCell(1).SetCellValue("1111");
//sheet1.GetRow(2).GetCell(1).SetCellValue(300);
//Force excel to recalculate all the formula while open
sheet1.ForceFormulaRecalculation = true;
if (File.Exists(@"e:/test.xls"))
{
File.Delete(@"e:/test.xls");
}
else
{
FileStream file2 = new FileStream(@"e:/test.xls", FileMode.Create);
hssfworkbook.Write(file2);
file2.Close();
}
file.Close();
MessageBox.Show("SUC");
}
catch(Exception ex)
{
MessageBox.Show("ERR");
}
}
其中需要注意的地方时:1,,如果模板中赋值过的地方再次赋值:sheet1.GetRow(2).GetCell(1).SetCellValue(true);
2,如果没有赋值,为空的地方:sheet1.CreateRow(3).CreateCell(3).SetCellValue(12345);
- NOPI用模板生成excel
- NOPI实现生成Excel数据表
- Nopi Excel下载功能
- NOPI操作Excel
- NOPI导出excel
- nopi导入导出excel
- C# NOPI读取Excel
- NOPI\\Excel导入数据
- winform下用NOPI导出excel怎么写
- 使用NOPI实现导出已有固定模板的Excel报表
- NOPI导出标准格式Excel
- 根据Excel模板生成Excel
- 用POI加载模板生成excel报表
- 根据模板生成Excel
- SpringMVC生成Excel模板
- C#利用NOPI处理Excel的代码
- Nopi导出excel 设置字体颜色
- C#利用NOPI处理Excel的代码
- js获取节点 dom操作
- 常见设计模式的解析和实现(C++)之十七-State模式
- 网页配色:叠柔配色法
- 图说TechCrunch Disrupt NY 很艺术很幽默
- Quartz integration within Spring for Invoke SQL stored procedure
- NOPI用模板生成excel
- 指针-----函数指针
- C++ CString string 转换 最简单的方法
- linux的命令行成了 -bash-3.2# 如何解决
- 转载Java反射详解
- 常见设计模式的解析和实现(C++)之十八-Iterator模式
- ORACLE同一个数据库下不同表结构之间的数据导入
- zip 的压缩原理与实现(lz77 算法压缩)
- 常见设计模式的解析和实现(C++)之十九-Memento模式