Convert Excel to CSV without Excel installed in ASP.NET -


I have a task of creating a class that can take an XLS file and convert it to a CSV file, but A grip, I can not install anything on the server like Excel or Jet drivers, and for this time. Must be 2.0 I thought of doing this with a filestream and stream reader, looking at the obstacles.

The code does not give me any error, it uploads the excel file and even creates a CSV file for it, but when I open the file there's no rows (and excel in it) There are rows in the file). All the data I see is always on 2 worksheet and I am wondering if the issue where my problem lies is that I am removing this code, any help would be greatly appreciated. :

  '' '& lt; Summary & gt; To change the XLS or XLSX file in CSV format, without the need to install any third party 'like' Excel or ACE / JAT drivers '' method '' & lt; / summary & gt; '' '& lt; Returns & gt; & Lt; / Returns & gt; '' '& Lt; Comment & gt; & Lt; / Comments & gt; Public Functions DoConvert (ByVal delimiter as the string, alternate ByVal is made as Boolean = true) Headers as new file stream (String.format ("{0}", ExcelFile.SourceFile) Try the slow stream, FileMode.Open, FileAccess.Read, FileShare.No) DataTable = GenerateDataTableFromXls (stream, ",", true) as the demat table if the table. Rows.Count & gt; 0 Then use the author = New Streamer (ExcelFile.TargetFile) for each line, as a datestre in the table. The light is in the form of DataColumn for each column in the form of first bullion =. Columns if not first author Type (",") otherwise the first = false end if the dim data = line (column.ColumnName). Ostring (). Replace ("", "" "" ") author. (String.Format ("" "{0}" ", data)) Next author. Publish () Next, finish the use of the Elsie Throw New Exception (Me.ReturnMessage) if 'CSV data exits, then I Tell the right, catch as an exception. Return message = Ex. Message () False Fault Try Try End '' '& lt; Summary & gt; Import files with '' 'delimited rows, columns'' '' & lt; / summary & gt; '' '& Lt; Ultimate name = "stream" & gt; To load strem & lt; / param & gt; '' '& Lt; Param name = "delimiter" & gt; String for imported line items & lt; / param & gt; '' '& Lt; Ultimate name = "Import header" & gt; The column headers are included with the import, (if true, then the first row will be added as a datacom), (if incorrect, the data will be the number of columns) & lt; / param & gt; Private function generateDataTableFromXls (as Streamline, stream as delimiter, as Import Headers Boolean) Dataty slow file as new streamer (stream, encoding. Default) Dim table as new datatyll Import the look of the rear middleholders into a dim column string () = file. ) .plate (for delimiters. ToCharArray ()) column columns for each column in the form of a string. Column Add (column) integer = file in the form of the next ALS thumb count. Readline (). Split (delimiter. Coachere) To calculate the table as the integer = 1 for the length () I. Column.Update (i.ToString ()) Next End if during the file. PEC ()> 0 table.rules (file.readline (). Split (delimiter cochrane ()) and catch-up exceeds Return message = X. Message (end) file. Close () file Return table Last function   

Any ideas?

Number of open source solutions that can be read (and in some cases) excel files are my favorites .

Epeplus reads and writes Excel 2007/2010 file using Open Office XML Format (XLSX).

EPPLUS does not have any external dependencies such as Excel or Jet. This legacy does not even support the .xls format. If you have to support legacy files, you may need to look at a commercial solution from there. I'm not aware of the unified open source solution that handles the old format.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -