表单名称和oledb问题过长的自动Excel工作表 [英] Automated Excel sheet with too long sheetname and oledb problem

查看:110
本文介绍了表单名称和oledb问题过长的自动Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我用机器生成的excel文件有问题.我没有机会更改导出的任何设置,而不得不使用这些文件.

问题:工作表名称比excel的允许大小长.当我尝试通过oledb导入excel数据时,出现oledbdataprovider错误22异常.
当我将工作表名称切成30个字符(如excel中的可见工作表名称)时,oledb找不到工作表.如果我在excel中重命名工作表名称并保存文件,则可以使用oledb完美运行导入.

我无法使用excel,因为我需要编写在服务器上运行并运行导入/计算且未在计算机上安装excel的服务.

有什么想法可以从C#读取或导入该文件吗?也许可以操纵工作表名称吗?这些文件是普通的旧xls文件btw.因此,没有带xml或其他内容的xlsx.

谢谢,感谢您的帮助..

Bjoern

Hi,

i got a problem with a machine generated excel file. I have no chance to alter any settings for the export and have to live with the files.

The problem: the sheetname is longer than the allowed size of excel. When i try to import the excel data via oledb i get an error 22 exception of the oledbdataprovider.
when i cut the sheetname to 30 chars (like the visible sheetname in excel), oledb does not found the sheet. If i rename the sheetname in excel and save the file, i can run the import with oledb flawlessly.

i cant use excel as i need to write a service that runs on a server and runs imports / calculations with no excel installed on the machine.

Any ideas if its possible to read or import that files from C#? Maybe its possible to manipulate the sheetname? The files are plain old xls files btw. So no xlsx with xml or whatever.

thanks and any help is appreciated..

Bjoern

推荐答案

可以在导入之前使用Microsoft.Office.Interop.Excel打开文件并循环浏览工作表以重命名具有长名称的工作表吗?
Can you open the file using Microsoft.Office.Interop.Excel and cycle through the sheets to rename any sheets with long names before importing?


这篇关于表单名称和oledb问题过长的自动Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆