mirror of
https://gitee.com/dotnetchina/MiniExcel.git
synced 2024-11-29 18:38:08 +08:00
Fix empty data reader issue. (#629)
Co-authored-by: Lukasz Arciszewski <lukasz.arciszewski@accenture.com>
This commit is contained in:
parent
c0c8621e94
commit
7ecf0ffe69
@ -143,7 +143,10 @@ namespace MiniExcelLibs.OpenXml
|
||||
if (_printHeader)
|
||||
{
|
||||
PrintHeader(writer, props);
|
||||
yIndex++;
|
||||
if (props.Count > 0)
|
||||
{
|
||||
yIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
while (reader.Read())
|
||||
|
@ -3,6 +3,7 @@ using MiniExcelLibs.Attributes;
|
||||
using MiniExcelLibs.OpenXml;
|
||||
using MiniExcelLibs.Tests.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using NSubstitute;
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -705,6 +706,19 @@ namespace MiniExcelLibs.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EmptyDataReaderIssue()
|
||||
{
|
||||
var path = PathHelper.GetTempPath();
|
||||
|
||||
var reader = Substitute.For<IDataReader>();
|
||||
MiniExcel.SaveAs(path, reader, overwriteFile: true);
|
||||
|
||||
var q = await MiniExcel.QueryAsync(path, true);
|
||||
var rows = q.ToList();
|
||||
Assert.Empty(rows);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [When reading Excel, can return IDataReader and DataTable to facilitate the import of database. Like ExcelDataReader provide reader.AsDataSet() · Issue #216 · shps951023/MiniExcel](https://github.com/shps951023/MiniExcel/issues/216)
|
||||
/// </summary>
|
||||
|
@ -24,6 +24,11 @@
|
||||
<PackageReference Include="ExcelDataReader.DataSet" Version="3.6.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="NPOI" Version="2.7.0" />
|
||||
<PackageReference Include="NSubstitute" Version="5.1.0" />
|
||||
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115.5" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user