zoukankan      html  css  js  c++  java
  • oledb 写入 office2010 以及发布到iis 遇到的奇怪问题总结

    这段时间在做Excel 导出升级,把之前的office2003 升级到 2010导出。

    一 利用oledb 写入 Excel 2010 的时候,怎么也打不开文件,最后调查的原因是

    需要修改连接字符串:string connString = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + excelPath + ";Extended Properties='Excel 12.0 xml; HDR=Yes; IMEX=0;'";

    关键在于要添加 xml。

    二  发不到IIS的时候又遇到一个奇怪的问题,当导出的数据大于1M的时候,倒出来的是一个空的文件,并且sheet名称被编码了。又是一顿查找,

    原因:"Since the Excel 2007 openxml format is zipped xml so the ACE driver OLEDB needs to read the whole file to unzip it. If the file is too large for the memory buffer, it gets cached out to disk and the location it uses is Temporary Internet Files for whatever user the app is running as. In the case of my customer, the web app is running as Network Service which means (we found this by using procmon):
    C:Documents and SettingsDefault UserLocal SettingsTemporary Internet FilesContent.MSO. To work around this, we manually created the Content.MSO directory and gave Network Service modify permissions to Content.MSO. ”

    那我们就开始修改吧 如图:

    这样设置一般机器就可以使用了,缺点是localsystem的权限过高。

    但是有的机器还是不好用,这时候就要检查IIS的身份验证,要把Asp.Net模拟禁用。

    三 用oledb创建sheet和插入数据一直保持一个连接未关闭的时候,我们可以直接 insert into sheet名 。。。。。

    但是当不在一个连接的时候 我们就需要使用 insert into [sheet名$],但是这样会导致数据格式乱的问题.

    为了过滤隐藏表,Oledb读取表会在表后面加上$符号,对于一些有公式的sheet,OleDb会创建一个隐藏表,但这些表没有加上$符号

  • 相关阅读:
    产品设计步骤
    浅谈公司经营的事业发展线
    项目经理的眼:一切都是项目
    IT软件的编程方向
    后记:IT软件人员学习的书籍
    12、产品经理要阅读的书籍
    11、项目经理要阅读的书籍
    7、项目活动的开展
    6、项目组人员绩效考核
    5、项目组人员培训
  • 原文地址:https://www.cnblogs.com/wanglg/p/3312138.html
Copyright © 2011-2022 走看看