一.POI简介 Jakarta POI 是apache的子项目,目标是处理ole2对象.它提供了一组操纵Windows文档的Java API 目前比较成熟的是HSSF接口,处理MS Excel(97-2002)对象.它不象我们仅仅是用csv生成的没有格式的可以由Excel转换的东西,而是真正的Excel对象,你可以控制一些属性如sheet,cell等等. 二.HSSF概况 HSSF 是Horrible SpreadSheet Format的缩写,也即“讨厌的电子表格格式”. 也许HSSF的名字有
先把数据库中的数据都导入到Excel表格中,把图片地址的路径全部转成绝对路径. 使用Npoi读取刚导出的Excle表格,把图片那个单元格的图片路径读出来,然后用文件流读取图片,然后通过Npoi把图片放到当前单元格中. //add picture data to this workbook. byte[] bytes = System.IO.File.ReadAllBytes(@"D:\MyProject\NPOIDemo\ShapeImage\image1.jpg"); int pic
using System.Collections.Generic; using System.Linq; using DOD = DocumentFormat.OpenXml.Drawing; using DODC = DocumentFormat.OpenXml.Drawing.Charts; using DODS = DocumentFormat.OpenXml.Drawing.Spreadsheet; using DOS = DocumentFormat.OpenXml.Spreadshe
调用word的com组件将400条数据导入word表格中耗时10分钟简直不能忍受,使用NPOI组件耗时4秒钟.但是NPOI中替换书签内容的功能不知道是不支持还是没找到. 辅助类 Excel表格数据与DataTable互转: using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.SS.UserModel; using NPOI.XSSF.UserModel;
源数据如图: 宏操作: 生成数据后: 关键操作:在excel中启用开发工具,添加宏,然后添加模块即可,编辑完代码后,自定义功能按钮即可. Sub MakeDataSource() Dim isExistDestinationSheet isExistDestinationSheet = False Dim i For i = 1 To Sheets.Count If Sheets(i).Name = "b" Then isExistDestinationSheet = True End