C#利用最新版的WPS实现导入导出

C#利用最新版的WPS实现导入导出

微软的EXCEl操作相信大家也知道,不方便,安装包太大,而且表格的数据量也只有6000多(是6000多还是60000多我就忘记了),在导出导入大量数据的就没办法,而wsp表格则实现了百万数据的容量,wps表格,而且安装包也小,操作更方便。下面利用最wps2015实现了一个简单的导入到出,参考@126/blog/static/410470052013818325357/文章,也可也参考一下wsp二次开发文档,相应的dll引用如下图:

技术分享


using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Excel; namespace WebApplication1 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Excel.Application appli = new Application(); /*wsp excel导出*/ /*Excel._Workbook wk = appli.Workbooks.Add(Type.Missing); Excel.Worksheet sheet = wk.ActiveSheet; sheet.Cells[1, 1] = "WPS表格测试"; wk.SaveAs(Server.MapPath("/2.xls"), Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); wk.Close(Type.Missing, Type.Missing, Type.Missing); System.Runtime.InteropServices.Marshal.ReleaseComObject(wk); System.Runtime.InteropServices.Marshal.ReleaseComObject(appli);*/ /*wps excel导入*/ Excel._Workbook wk = appli.Workbooks.Open(Server.MapPath("/2.xls")); Excel.Worksheet sheet = wk.Worksheets.get_Item(1); Excel.Range range = sheet.UsedRange; string data = ((Excel.Range)range.get_Item(1, 1)).Text; Response.Write(data); } } }


本文标题:C#利用最新版的WPS实现导入导出,由WPS精选分享
如果您觉得这篇文章不错,请使用分享工具推荐到您喜欢的微博、网站或者论坛

所属分类:WPS文字
本文标签:互联网开源as软件开发码迷
发布时间:2016-02-18