Solved

convert CSV to xlsx

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Eagerly loading related objects in entity framework 5 29
Service Controller 1 23
Sent email using Shared Mailbox from outlook in C# 5 24
VB.NET 2008 - SQL Timeout 9 24
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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