为什么java读不了.xlsx的excel文件只能读.xls的,难道是因为我的jxl.jar包太久了?
网上说最新版的下载下来也没有用,有没有大神有解决方法啊?如果有可以读.xlsx的jxl.jar请发到我的邮箱774524998@qq.com,万分感谢...
网上说最新版的下载下来也没有用,有没有大神有解决方法啊?如果有可以读.xlsx的jxl.jar请发到我的邮箱774524998@qq.com,万分感谢
展开
展开全部
建议您还是说服用户把文档格式改成2003吧。。。jxl暂时没JAR包支持2007或2010.。。
当然换POI 可行,但整个项目里凡是以前用到jxl的地方都要换。。。风险是不是太大了。。
当然换POI 可行,但整个项目里凡是以前用到jxl的地方都要换。。。风险是不是太大了。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
兄弟 jxl不支持office2007
还是用Apache POI 插件吧
还是用Apache POI 插件吧
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-03-24
展开全部
百度知道不让发网址。你在百度里搜索:大气象
在我的博客园博客里有详细代码。
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Excel;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Bind();
}
private void Bind()
{
//模板文件
string TempletFileName = Server.MapPath("template/") + "template.xlsx";
//导出文件
string ReportFileName = Server.MapPath("xls/") + "out.xlsx";
string strTempletFile = Path.GetFileName(TempletFileName);
//将模板文件复制到输出文件
FileInfo mode = new FileInfo(TempletFileName);
mode.CopyTo(ReportFileName, true);
//打开excel
object missing = Missing.Value;
Application app = null;
Workbook wb = null;
Worksheet ws = null;
Range r = null;
//
app = new Microsoft.Office.Interop.Excel.Application();
wb = app.Workbooks.Open(ReportFileName, false, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
app.Visible = true;
//得到WorkSheet对象
ws = (Worksheet)wb.Worksheets.get_Item(1);
//添加或修改WorkSheet里的数据
ws.Cells[1, 1] = "100";
ws.Cells[2, 1] = "100";
ws.Cells[2, 2] = "100";
//代码里写个公式
r = (Range)ws.Cells[2, 3];
r.Formula = "=A2*B2";
//输出Excel文件并退出
wb.Save();
wb.Close(null, null, null);
app.Workbooks.Close();
app.Application.Quit();
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
ws = null;
wb = null;
app = null;
}
}
在我的博客园博客里有详细代码。
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Excel;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Bind();
}
private void Bind()
{
//模板文件
string TempletFileName = Server.MapPath("template/") + "template.xlsx";
//导出文件
string ReportFileName = Server.MapPath("xls/") + "out.xlsx";
string strTempletFile = Path.GetFileName(TempletFileName);
//将模板文件复制到输出文件
FileInfo mode = new FileInfo(TempletFileName);
mode.CopyTo(ReportFileName, true);
//打开excel
object missing = Missing.Value;
Application app = null;
Workbook wb = null;
Worksheet ws = null;
Range r = null;
//
app = new Microsoft.Office.Interop.Excel.Application();
wb = app.Workbooks.Open(ReportFileName, false, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
app.Visible = true;
//得到WorkSheet对象
ws = (Worksheet)wb.Worksheets.get_Item(1);
//添加或修改WorkSheet里的数据
ws.Cells[1, 1] = "100";
ws.Cells[2, 1] = "100";
ws.Cells[2, 2] = "100";
//代码里写个公式
r = (Range)ws.Cells[2, 3];
r.Formula = "=A2*B2";
//输出Excel文件并退出
wb.Save();
wb.Close(null, null, null);
app.Workbooks.Close();
app.Application.Quit();
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
ws = null;
wb = null;
app = null;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询