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

feat: support insert sheet #709

Merged
merged 3 commits into from
Jan 19, 2025

Conversation

izanhzh
Copy link
Member

@izanhzh izanhzh commented Jan 16, 2025

close #646 , #551

  • 重构了 SheetStyleBuilder 以实现新增Sheet,使用 XmlReader 读取旧style.xml,使用 XmlWriter 在旧的基础上进行最追加修改style.xml
  • 必须使用FastMode,因为要Update压缩包
  • 新增 SheetStyleElementInfos 用于记录新旧style.xml的Element简要信息,方便修改逻辑处理
  • 新增 SheetStyleBuildContext 用于记录Build上下文信息,方便修改逻辑处理
  • 新增 SheetStyleBuildResult 用于记录Build结果,这里会输出一个 CellXfIdMap,因为新增Sheet会导致创建Cell要设置的样式Id发生偏移,这里做了一个映射,这样就可以正确的应用新增的CellXf了

@izanhzh izanhzh requested a review from shps951023 January 16, 2025 03:09
@izanhzh

This comment was marked as resolved.

@izanhzh
Copy link
Member Author

izanhzh commented Jan 16, 2025

目前insert sheet会存在一个问题:

  • 如果原来的Excel是不是由MiniExcel创建的,会导致最终的Excel无法进行新增和删除Sheet操作,必须重新保存下让Excel重新刷新内部的xml数据,才能进行这些操作操作,猜测是因为原来的sheet与新增的Sheet的xmlns不一致导致
  • 如果原来的Excel是由MiniExcel创建,则不会存在此问题,因为所有Sheet的xmlns是一样的
    image
    image
    image

此问题导致结果稍有瑕疵,但也勉强可以接受,不太好解决,除非重构所有xml的创建,让其保持相同的xmlns,工程量太大

@shps951023 shps951023 merged commit 578d98c into mini-software:master Jan 19, 2025
3 checks passed
@izanhzh izanhzh deleted the feat-insert-sheet branch January 20, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants