3

New at C# using visual studio 2010 and trying to get output in a text file from an excel sheet. The excel sheet contains only one column with numeric values like this:

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.

2
  • I am trying to do using C#. Please help. Commented Jul 17, 2012 at 18:41
  • 2
    Use the Excel Interop to get access to the excel file, then format and write it to your file in C#. Also, remember Excel cells are 1-based indexes, rather than 0. Commented Jul 17, 2012 at 18:41

1 Answer 1

1

This should do it using the 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:

Sign up to request clarification or add additional context in comments.

1 Comment

he want to write that to text file. I think Datalist with repeat column is correct control to display this data in required format on webpage and not gridview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.