将excel文件转换为文本 [英] Convert excel file to text

查看:147
本文介绍了将excel文件转换为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将excel文件转换为文本格式而不在c#.net版本4.0中安装ms office

How to convert excel file to Text format without installing ms office in c#.net version 4.0

推荐答案

嗯,它实际上不是转换。基本上你读取Excel文件并将其写入文本文件。



请参阅此处阅读Excel文件 [ ^ ]

< br $> b $ b和



此处为撰写文本文件 [ ^ ]



当然,您必须从每个链接中推断出相关材料并将它们组合起来以实现您的目标。
Well, it is not really a conversion. Basically you read the Excel file and write it to a text file for example.

See here for reading an Excel file[^]

and

here for writing a text file[^]

Of course you will have to extrapolate the pertinent material from each link and combine them to accomplish your goal.


所有,正如在解决方案1中正确陈述的那样,这不是真正的转换。 Excel和文本数据之间没有一对一的对应关系,因此您需要在两者之间定义一些映射。并且您应该期望在大多数情况下将数据保存为文本将导致一些信息丢失和信息增加 entropy 。请参阅:

http://en.wikipedia.org/wiki/Map_%28mathematics %29 [ ^ ],

http://en.wikipedia.org/wiki/Data_mapping [ ^ ],

http://en.wikipedia.org/wiki/Entropy_%28information_theory%29 [ ^ ]。



如果你需要阅读没有安装Office的Excel(很容易理解),这样做的主要方法是使用Open XML SDK:



http://www.microsoft.com/en-us/do wnload / details.aspx?id = 30425 [ ^ ]。



这样,您可以支持新的基于XML的Office格式(例如.DOCX,.XLSX), ECMA-376标准:

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats [ ^ ],

http://en.wikipedia.org/wiki/Office_Open_XML [ ^ ]。



这样,您可以在没有安装Office的情况下工作。此外,第三方软件支持这些文档。请查看我过去的答案:

将Office文档转换为PDF而不互操作 [ ^ ],
需要一个相当独特的WPF文本编辑器控件 [ ^ ],

您好如何使用c#.net 在Windows应用程序中显示word文件[ ^ ],

阅读没有使用Interop.word dll的word文件...不想在IIS中安装单词。 [ ^ ]。



这是另一种选择: http://npoi.codeplex.com/ [ ^ ]。



Microsoft解释了为什么使用Office互操作在某些设置中不适用:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757# kb2 [ ^ ],

<小时ef =http://support.microsoft.com/kb/257757/en-us> http://support.microsoft.com/kb/257757/en-us [ ^ ]。



-SA
First of all, as it is correctly stated in Solution 1, this is not really a conversion. There is no one-to-one correspondence between Excel and text data, so you need to define some mapping between the two. And you should expect that saving data as text in most cases will cause some loss of information and increase of information entropy. Please see:
http://en.wikipedia.org/wiki/Map_%28mathematics%29[^],
http://en.wikipedia.org/wiki/Data_mapping[^],
http://en.wikipedia.org/wiki/Entropy_%28information_theory%29[^].

If you need to read Excel without installation of Office (quite understandable), the main method of doing so would be using Open XML SDK:

http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^].

This way, you can work without Office installed. Also, the documents are supported by 3rd-party software. Please see my past answers:
Convert Office-Documents to PDF without interop[^],
Need a rather unique WPF text editor control[^],
Hi how can i display word file in windows application using c#.net[^],
Read a word file without using Interop.word dll...Do not want to install word in IIS..[^].

This is another option: http://npoi.codeplex.com/[^].

Microsoft explained why using Office interop would be unsuitable in some settings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

—SA


引用Excel对象库,项目中的COM库。然后读取excel文件并一次写入一行文本文件。
Reference Excel Objects Library , a COM library in your project. Then Read the excel file and write to text file one line at a time.


这篇关于将excel文件转换为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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