[英]Write text file from excel using C#
New at C# using visual studio 2010 and trying to get output in a text file from an excel sheet. 使用Visual Studio 2010在C#上新增,并尝试从excel表中获取文本文件中的输出。 The excel sheet contains only one column with numeric values like this: excel表只包含一个包含数字值的列,如下所示:
ColumnA
-------
222
333
444
555
666
777
888
999
877
566
767
678
767
I am trying to get the output in the text file like this: 我试图在文本文件中获取输出,如下所示:
222, 333, 444,
555, 666, 777,
888, 999, 877,
566, 767, 678,
767
Thanks in advance. 提前致谢。
This should do it using the BytesCout SpreadSheet SDK : 这应该使用BytesCout SpreadSheet SDK :
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Bytescout.Spreadsheet;
namespace Converting_XLS_to_TXT
{
class Program
{
static void Main(string[] args)
{
// Create new Spreadsheet from SimpleReport.xls file
Spreadsheet document = new Spreadsheet("SimpleReport.xls");
// delete output file if exists already
if (File.Exists("SimpleReport.txt")){
File.Delete("SimpleReport.txt");
}
// save into TXT
document.Workbook.Worksheets[0].SaveAsTXT("SimpleReport.txt");
}
}
}
References: 参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.