npoi

c# NPOI 导出23万条记录耗时12秒

♀尐吖头ヾ 提交于 2019-11-27 17:01:19
先上测试代码: string connectionString = "Server=localhost;Initial Catalog=******;User ID=sa;Password=******;"; List<TestData> datas = null; using (SqlConnection db = new SqlConnection(connectionString)) { datas = db.Query<TestData>("SELECT * FROM TestData").ToList(); } System.Console.WriteLine($"数据源对象 {typeof(TestData).GetProperties().Length} 个字段,共 {datas.Count} 条记录,大小 {BinarySerializeHelper.SerializeToBytes(datas).Length/1000/1000} M"); Task.Run(() => { while (true) { System.Console.WriteLine($"{DateTime.Now} 内存 : {GC.GetTotalMemory(false) / 1000 / 1000} M"); Thread.Sleep(1000); } }); Stopwatch sw

How can columns be set to 'autosize' in Excel documents created with NPOI?

南笙酒味 提交于 2019-11-27 15:54:06
问题 NPOI is a .NET port of the Java POI project, which allows one to read and write Microsoft Excel documents (as well as other Office formats). NPOI 1.2.2 has introduced support for 'autosizing' columns, whereby the column is set to the width of the widest cell entry in the column. However, there are many reports that this does not work. So is it possible? 回答1: I've posted this just to answer it, so as to provide a record. It is possible to make columns autosized using NPOI, but you have to add

SSIS Script Task cant find reference to assembly

梦想与她 提交于 2019-11-27 06:52:03
问题 I have an SSIS package that uses a script task to populate a datatable with data from a variety of different file types including excel. I am using NPOI to read in the data from Excel and have put the NPOI.dll file in the same folder as the SSIS package and added it as a reference in the script task. I'm a Noob when it comes to NPOI so I'm only tinkering at the moment, but even still I have fallen at the first hurdle! My script contains the code below (which i copied from this SA answer):

ASP.NET MVC Ajax下载文件(使用NPOI向现有的excel模板文件里面添加数据)

杀马特。学长 韩版系。学妹 提交于 2019-11-27 04:12:24
View Html.DevExpress().Button(DevExpressButtonHelper.AddButton(ViewBag.Form, "Export", "Export", 70, false)).GetHtml(); Javascript 调用StoreLocalViewData controller的方法主要是用来把传入export的参数, 然后使用(ViewDataDictionary)LocalViewData 存储. var url = "@Url.Action("BillExportFile", ViewBag.Controller)"; 这个是在controller里面从数据获取需要导出的数据, 然后返回一个文件. function MainExport(){ var la_HAWB = GetSelectedValueByField(MainGridView,"HAWB",1); if(la_HAWB.length == 0 ) { Messagebox("1012","","","","0") return false; } var ljs_Json = GenerateJson("HAWB", la_HAWB,"String"); ljs_Json = "["+ ljs_Json.substring(0, ljs_Json.length -

Excel.资料

百般思念 提交于 2019-11-27 02:57:58
1、没安装 Excel的机子,如操作Excel:   1.1、2007及以上版本 可以使用 微软的 "openxml sdk"   1.2、第三方:npoi、spire 等 2、资料:  2.1、Web C# 导出Excel 方法总结 - 巫威 - 博客园.html( https://www.cnblogs.com/shengwei/p/4478591.html )   ZC:2种方式:微软官方方式、NPOI(ZC: 据说 "(2.0版本后受到微软支持)")  2.2、用C#操作word替换字符,不用npoi,改用spire - 大破锣 - 博客园.html( https://www.cnblogs.com/dapolo/p/4393205.html )   ZC:这是一个 喷NPOI 的支持的,且npoi操作word 貌似也不是太好  2.3、不安装office的情况下如何实现对excel的导入导出 - zjs江南 - 博客园.html( https://www.cnblogs.com/zjsjiangnan/archive/2013/12/11/3469386.html )   ZC:内容摘抄:     对于07/10及以后的版本,可以采用openxml sdk,因为07/10都是open xml标准的,利用open xml

C# create/modify/read .xlsx files

不羁岁月 提交于 2019-11-26 17:52:08
I am looking for a way to create, modify, read .xlsx files in C# without installing Excel or creating files on the server before giving to the user to download. I found NPOI http://npoi.codeplex.com/ which looks great but supports .xls not .xlsx I found ExcelPackage http://excelpackage.codeplex.com/ which looks great but has the additional overhead of creating the file on the server before it can be sent to the user. Does anyone know of a way around this? I found EPPlus http://epplus.codeplex.com but I am not not certain if this requires creation of a file on the server before it can be sent

How to read file using NPOI

天涯浪子 提交于 2019-11-26 06:27:21
问题 I found NPOI is very good to write Excel files with C#. But I want to open, read and modify Excel files in C#. How can I do this? 回答1: Simple read example below: using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; //..... private void button1_Click(object sender, EventArgs e) { HSSFWorkbook hssfwb; using (FileStream file = new FileStream(@"c:\test.xls", FileMode.Open, FileAccess.Read)) { hssfwb= new HSSFWorkbook(file); } ISheet sheet = hssfwb.GetSheet("Arkusz1"); for (int row = 0; row <=

C# create/modify/read .xlsx files

十年热恋 提交于 2019-11-26 05:38:53
问题 I am looking for a way to create, modify, read .xlsx files in C# without installing Excel or creating files on the server before giving to the user to download. I found NPOI http://npoi.codeplex.com/ which looks great but supports .xls not .xlsx I found ExcelPackage http://excelpackage.codeplex.com/ which looks great but has the additional overhead of creating the file on the server before it can be sent to the user. Does anyone know of a way around this? I found EPPlus http://epplus.codeplex