Solved

convert CSV to xlsx

Posted on 2010-09-22
2
2,412 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 83

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Iterate a dictionnary to change values 4 53
c# string handling 1 27
Word Directory is not in the drop down list 4 25
Error when loading the database 16 57
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

13 Experts available now in Live!

Get 1:1 Help Now