Skip to content

Commit

Permalink
Merge pull request #21 from dynamicweb/dbe/18708-Fix-Excel-Read-For-E…
Browse files Browse the repository at this point in the history
…mpty-Columns

Read cells with empty values correctly
  • Loading branch information
frederik5480 authored Apr 2, 2024
2 parents b3e9f80 + cca799a commit c3357f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.11</Version>
<Version>10.0.12</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Title>Excel Provider</Title>
<Description>Excel Provider</Description>
Expand Down
13 changes: 6 additions & 7 deletions src/ExcelReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ private void LoadExcelFile()
{
var hasValue = false;
var wsRow = worksheet.Cells[rowNum, 1, rowNum, worksheet.Dimension.End.Column];
var row = dataTable.Rows.Add();
var c = 0;
foreach (var cell in wsRow)
var row = dataTable.Rows.Add();
for(var colNum = 1; colNum <= worksheet.Dimension.End.Column; colNum++)
{
row[c] = cell.Text;
string cellText = wsRow[rowNum, colNum].Text;
row[colNum - 1] = cellText;

if (!string.IsNullOrWhiteSpace(cell.Text))
hasValue = true;
c++;
if (!string.IsNullOrWhiteSpace(cellText))
hasValue = true;
}

if (!hasValue)
Expand Down

0 comments on commit c3357f7

Please sign in to comment.