Note that there are some explanatory texts on larger screens.

plurals
  1. POAsp.net using oledb to export excel file returns empty excel file
    primarykey
    data
    text
    <p>I am using asp.net oledb to export information to excel file. I encounter problems when the information to export becomes too big, in this case the code I have given below, the excel file generated becomes an empty spreadsheet. </p> <p>If I changed the loop to 1123 for insertion of the rows. The generated excel file is fine, 1125 rows, and 4 columns shown.</p> <p>A test program in windows form is also working fine regardless of how many rows.</p> <p>Code has been simplified, "information ..." in the sql insertion command represents 1803 characters.</p> <pre><code>ExcelObjConn = "Provider=Microsoft.Ace.OLEDB.12.0;" &amp; _ "Data Source=" &amp; fileName &amp; ";Extended Properties=Excel 12.0 XML" ExcelConnection = New System.Data.OleDb.OleDbConnection(ExcelObjConn) ExcelConnection.Open() Try SqlCommand = "CREATE TABLE ABC ([row1] text, [row2] text, [row3] text, [row4] text)" ExcelCommand = New OleDb.OleDbCommand(SqlCommand, ExcelConnection) ExcelCommand.ExecuteNonQuery() ExcelCommand.Dispose() For i As Integer = 0 To 1124 SqlCommand = "Insert into ABC ([row1], [row2], [row3], [row4]) Values ('information...', 'information ...', 'information ...', 'information ...')" ExcelCommand = New OleDb.OleDbCommand(SqlCommand, ExcelConnection) ExcelCommand.ExecuteNonQuery() ExcelCommand.Dispose() Next Catch ex As Exception Finally If ExcelConnection IsNot Nothing Then ExcelConnection.Close() ExcelConnection.Dispose() End If End Try </code></pre> <p>What should I do? Thanks.</p> <p><strong>Workaround</strong>:</p> <p>Hello, I couldn't find a solution to my problem as well. What I did eventually was to run the process using another separate windows service. The code works perfectly fine running from a windows form or service program, but not asp.net, not sure why. Hope this workaround helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload