Note that there are some explanatory texts on larger screens.

plurals
  1. POSpreadsheet Upload
    text
    copied!<p>Getting a weird problem when uploading a spreadsheet via C#.</p> <p>Here's an example of the spreadsheet I'm using:</p> <pre><code>JournalISSN ----------- 1650327 223956 1651781 9254927 3064530 9209964 924977X &lt;- this is causing an error 3768716 </code></pre> <p>My upload code (snipped for brevity)</p> <pre><code>string connectionString = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + Server.MapPath("/admin/journals/upload.xls") + "; Extended Properties=\"Excel 8.0;HDR=YES;\""; DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb"); using (DbCommand Command = Connection.CreateCommand()) { Command.CommandText = "SELECT [JournalISSN], JournalTitle, JournalDescription, ImpactFactor, Psychology " + "FROM [Sheet1$]"; using (DbDataReader DataReader = Command.ExecuteReader()) { while (DataReader.Read()) { Response.Write(string.IsNullOrEmpty(DataReader["JournalISSN"].ToString()) + "&lt;br/&gt;"); } } </code></pre> <p>Now what happens, is when the DataReader gets to the row with the "X" in the "JournalISSN" column, it returns True (so it's null/ empty), all other columns return false. So the problem seems to be that whenever a column contains a character that is not numeric, it does not get pulled out during the upload.</p> <p>A few things i've tried:</p> <ul> <li>Moving the 'X' to different positions in the text (ie. 111X111)</li> <li>Changing to a different letter</li> <li>Deleting the cell and starting again</li> <li>Setting the format type in excel to "General" - applied on all rows.</li> </ul> <p>Would be grateful for any help/ insight as to why this is happening.</p> <p>Cheers, Sean</p>
 

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