简体   繁体   English

使用C#从excel写入文本文件

[英]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.

相关问题 使用C#将数据从Excel工作表写入文本文件 - Write the data from an Excel sheet to the text file using C# 使用 C# 将信息从列表写入 Excel 文件 - Write info from list to Excel file using C# C#从文本文件写入listView - C# Write from text file to listView 将范围值从 excel 文件写入 C# 中的另一个 excel - Write Range Values from an excel file to another excel in C# 如何在c#中将一些文本写入excel文件 - How to write some text to an excel file in c# 1)如何将Excel写入memorystream…2)如何使用Micosoft.Office.Interop.Excel和c#从浏览器下载Excel文件 - 1) how to write excel to memorystream…2) how to download excel file from browser…using Micosoft.Office.Interop.Excel and c# 使用CsvHelper以动态方式从excel中写入csv文件 - Write csv file using CsvHelper, from excel in a dynamic way c# 如何使用c#从XML文件读取特定数据并将其写入到现有Excel工作表 - How to Read a particular Data from XML file and Write it to an Existing Excel Sheet using c# 如何使用 C# 中的 NPOI 从现有 excel 文件中的列表中写入元素? - How to write element from a list in a existing excel file using NPOI in C#? C# 使用 Interop 写入打开的 Excel 文件 - C# Write to an open Excel file using Interop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM