Solved

convert CSV to xlsx

Posted on 2010-09-22
2
2,383 Views
Last Modified: 2012-05-10
Hello
The CSV file has data more than 66000 rows which is not supported by .xls format as it will trim the rows. Is there any way to convert the CSC to .XLSX format. I am using thr below code to convert to normal xls, can the same be changed.

TIA
Senz
public void SaveAsWorkbook(string strCSV, string strXLS)

        {

            excelApplicationClass = new Excel.Application();



            Workbook doc = excelApplicationClass.Workbooks.Open(strCSV, false, Missing.Value, Missing.Value, Missing.Value,

                                        Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,

                                            Missing.Value, Missing.Value);

            

            Console.WriteLine("ReadingCSV File........");



            doc.SaveAs(strXLS, XlFileFormat.xlWorkbookNormal, Missing.Value, Missing.Value, Missing.Value, Missing.Value,

            XlSaveAsAccessMode.xlExclusive, Missing.Value, false, Missing.Value, Missing.Value);





            doc.Saved = true;

            Console.WriteLine("Converted CSV to XLS file");

            excelApplicationClass.Quit();

            

        }

Open in new window

0
Comment
Question by:Senz79
2 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 33740963
Open the "normal xls" in Excel 2007/2010 and see what it does with it.  Unless it is formatted wrong, it will open it.
0
 
LVL 4

Accepted Solution

by:
Senz79 earned 0 total points
ID: 33741073
This worked

doc.SaveAs(strXLS, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now