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

2.2.0-beta2版本以Append方式导出多个sheet时,发生“Tablename is not unique”错误 #66

Closed
Superllb93 opened this issue Mar 25, 2020 · 8 comments
Labels
bug Something isn't working
Milestone

Comments

@Superllb93
Copy link

2.2.0-beta2版本以Append方式导出多个sheet时,当Append的ICollection均为空集合时,报 “Tablename is not unique”错误,比如:

new ExcelExporter().Append(new List<Student>()).Append(new List<Teacher>()).ExportAppendData("test.xlsx");

image

详细错误信息如下:

System.ArgumentException
  HResult=0x80070057
  Message=Tablename is not unique
  Source=EPPlus
  StackTrace:
   at OfficeOpenXml.Table.ExcelTableCollection.Add(ExcelAddressBase Range, String Name)
   at Magicodes.ExporterAndImporter.Excel.Utility.ExportHelper`1.AddHeader()
   at Magicodes.ExporterAndImporter.Excel.Utility.ExportHelper`1.AddHeaderAndStyles()
   at Magicodes.ExporterAndImporter.Excel.Utility.ExportHelper`1.Export(ICollection`1 dataItems)
   at Magicodes.ExporterAndImporter.Excel.ExcelExporter.Append[T](ICollection`1 dataItems)
   at Magicodes.IE.Excel.Program.Export() in E:\Technology\Magicodes.IE.Excel\Magicodes.IE.Excel\Program.cs:line 29
   at Magicodes.IE.Excel.Program.Main(String[] args) in E:\Technology\Magicodes.IE.Excel\Magicodes.IE.Excel\Program.cs:line 15

@xin-lai 请帮忙尽快解决,谢谢

@xin-lai xin-lai added the bug Something isn't working label Mar 25, 2020
@xin-lai xin-lai added this to the 2.2 milestone Mar 25, 2020
@xin-lai
Copy link
Collaborator

xin-lai commented Mar 25, 2020

收到。这种情形我们确实没有考虑。

@Superllb93
Copy link
Author

可对ExportHelper类里的AddHeader()方法进行如下修改

image

亲测可用 @xin-lai ,本地代码无法push,请帮忙验证,

@xin-lai
Copy link
Collaborator

xin-lai commented Mar 25, 2020

收到,这个问题我们是清楚如何处理的。

@xin-lai
Copy link
Collaborator

xin-lai commented Mar 25, 2020

非常感谢!

xin-lai pushed a commit that referenced this issue Mar 26, 2020
@xin-lai
Copy link
Collaborator

xin-lai commented Mar 26, 2020

2020.03.26
【Nuget】版本更新到2.2.0-beta4
【Excel多Sheet导出】修复#66,并添加单元测试

@xin-lai xin-lai closed this as completed Mar 26, 2020
@ZoeyuYK
Copy link

ZoeyuYK commented Mar 3, 2021

修复之后,如果两个ICollection均为空集合,无异常,如第二个ICollection为空集合,仍然报 “Tablename is not unique”错误

@ZoeyuYK
Copy link

ZoeyuYK commented Mar 3, 2021

@xin-lai

@qcjxberin
Copy link

Excel多Sheet导出 有没有Demo的?正好在找这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants