Solved

convert CSV to xlsx

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…

837 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