如何在c#中从excel自动生成列? [英] how to auto generate column from excel in c#?

查看:339
本文介绍了如何在c#中从excel自动生成列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下。如何从excel或.dbf生成列。或者csv,所以我的程序可以自动检测出有多少列?

i有一个例子。

请看下面的图片



http:// imageshack。 us / photo / my-images / 14 / qjpa.jpg / [ ^ ]

解决方案

您必须为您希望能够阅读的不同文件类型执行不同的操作。



CSV文件很简单 - 因为它是一个文本文件。您可以打开文件,阅读第一行并计算逗号(如果第一行包含可能包含逗号的带引号的字符串,则可能需要处理引号)。



对于DBF文件,XLS文件和其他具有更复杂结构的文件,您通常会使用第三方库来读取文件,并使用该库的API来发现文件中存在多少列。


嗨..

访问此链接

http://stackoverflow.com/questions/2884356/how-do-i-auto-size-columns-through-the-excel-interop-objects [ ^ ]


i want to ask. how can i generate column from excel or .dbf. or csv, so my program can detect how much column in there automatically ?
i have an example .
please see the picture below

http://imageshack.us/photo/my-images/14/qjpa.jpg/[^]

解决方案

You'll have to do different things for the different file types you want to be able to read.

A CSV file is easy - because it's a text file. You can just open the file, read the first line & count the commas (you may need to process quotes, if the first line contains quoted strings that may contain commas).

For DBF files, XLS files and others with more complex structures you would normally use a 3rd party library to read the file, and use that library's API to discover how many columns exist in the file.


Hi..
visit this link
http://stackoverflow.com/questions/2884356/how-do-i-auto-size-columns-through-the-excel-interop-objects[^]


这篇关于如何在c#中从excel自动生成列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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