Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When reading Excel, can return IDataReader and DataTable to facilitate the import of database. Like ExcelDataReader provide reader.AsDataSet() #216

Closed
yfl8910 opened this issue Apr 22, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@yfl8910
Copy link
Contributor

yfl8910 commented Apr 22, 2021

No description provided.

@shps951023 shps951023 added the enhancement New feature or request label Apr 27, 2021
@shps951023
Copy link
Member

v 0.13.5 support this

e.g

            var path = PathHelper.GetNewTemplateFilePath();
            var value = new[] { new { Test1="1",Test2=2 }, new { Test1 = "3", Test2 = 4 } };
            MiniExcel.SaveAs(path, value);

            {
                var dt = MiniExcel.QueryAsDataTable(path, true);
                var columns = dt.Columns;
                Assert.Equal("Test1", dt.Columns[0].ColumnName);
                Assert.Equal("Test2", dt.Columns[1].ColumnName);
                Assert.Equal("1", dt.Rows[0]["Test1"]);
                Assert.Equal((double)2, dt.Rows[0]["Test2"]);
                Assert.Equal("3", dt.Rows[1]["Test1"]);
                Assert.Equal((double)4, dt.Rows[1]["Test2"]);
            }

            {
                var dt = MiniExcel.QueryAsDataTable(path, false);
                Assert.Equal("Test1", dt.Rows[0]["A"]);
                Assert.Equal("Test2", dt.Rows[0]["B"]);
                Assert.Equal("1", dt.Rows[1]["A"]);
                Assert.Equal((double)2, dt.Rows[1]["B"]);
                Assert.Equal("3", dt.Rows[2]["A"]);
                Assert.Equal((double)4, dt.Rows[2]["B"]);
            }

shps951023 added a commit that referenced this issue Apr 30, 2021
- [New] Support QueryAsDataTable method [#216](#216)
- [New] SaveAs support IDataReader value parameter [#211](#211)
- [Bug] Fix numeric format string will be cast to numeric type [#I3OSKV](https://gitee.com/dotnetchina/MiniExcel/issues/I3OSKV)
- [Opt] Optimize SaveAs convert value type logic to improve performance
@shps951023 shps951023 moved this to Done in MiniExcel project Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants