Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert CSV to xlsx

Posted on 2010-09-22
2
Medium Priority
?
2,729 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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