利用GemBox库转换Excel格式
2015-06-11 14:22
513 查看
下文是把xls转成xlsx
GemBox同样可以用NuGet获取到,不过这是一个付费的dll, 但可以使用它的免费功能,在格式转换上面是没有什么限制的,免费使用注意下面这行
SpreadsheetInfo.SetLicense(“FREE-LIMITED-KEY”);
try { var dlgOpen = new OpenFileDialog { Title = @"导入Excel", Filter = @"所有文件|*.*|Excel文件(*.xls)|*.xls|Excel2007|*.xlsx|CSV文件|*.csv" }; if (dlgOpen.ShowDialog() == DialogResult.OK) { #region 把Excel导入表格中 using (FileStream fs = File.OpenRead(dlgOpen.FileName)) { var extension = Path.GetExtension(dlgOpen.FileName); if (extension != null) { #region Excel2003,利用GemBox库转成Excel2007 long len = fs.Length; byte[] buffer = new byte[len]; fs.Read(buffer, 0, (int)len); fs.Close(); SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); var ef = ExcelFile.Load(dlgOpen.FileName); MemoryStream fsNew = new MemoryStream(buffer, true); ef.Save(fsNew, new XlsxSaveOptions()); c_reoGridControl.Load(fsNew, FileFormat.Excel2007); #endregion } } #endregion SetColumnStyle(); } } catch (Exception ex) { _errMsg = ex.ToString(); MsgBox.Error(_errMsg); }
GemBox同样可以用NuGet获取到,不过这是一个付费的dll, 但可以使用它的免费功能,在格式转换上面是没有什么限制的,免费使用注意下面这行
SpreadsheetInfo.SetLicense(“FREE-LIMITED-KEY”);
相关文章推荐
- 交叉编译libusb,pcsc-lite,ccid
- 字符串函数
- java 跳出多层循环
- androidstudio设置项目编码
- html5,audio标签的autoplay="autoplay"在iphone上无法播放的问题
- 屏幕分辨率
- Linux内核驱动之poll和select
- asp.net MVC 常见安全问题及解决方案
- Chrome 插件 -- Vimium
- 使用MyBatis_Generator生成Dto、Dao、Mapping
- Hadoop平台优化综述(一)
- #提高Android Studio流畅度
- Kernel panic-not syncing:attempted to kill init!
- Android快速开发框架——AndroidAnnotations(Code Diet)
- WEB应用环境的搭建(一)配置Tomcat步骤
- Apple Watch视频教程(连载)
- SAT数学三角函数相关公式介绍
- 01 关系型数据库基础理论
- Material Design
- ffmpeg结构体以及函数介绍(三)