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

WorkSheet.Add Errors occur when the template Sheet is used, such as formulas, definition names, conditional formats, and external workbook links #1663

Open
minren118 opened this issue Nov 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@minren118
Copy link

EPPlus usage

Noncommercial use

Environment

Windows

Epplus version

7.4.2.1079

Spreadsheet application

Excel365

Description

When I use the WorkSheet.Add interface, I find that the definition name is copied, missing the workbook name is not copied, and it also raises an error if there is an external workbook link.

I have two workbooks, src1 and src2. In sheet1 of src1, there are formulas that reference src1's sheet2 worksheets and reference the workbook names. In sheet1 of src1, there are conditional format cells that reference src1's sheet2 worksheets. In the dst workbook, Using the WorkSheets.Add method, src1's sheet1 was passed in as a template and ended up with an error in the dst workbook's newSht.

image

image

image

image

image

            using (ExcelPackage excelPackage = new ExcelPackage("src1.xlsx"))
            {
                var copiedSht=excelPackage.Workbook.Worksheets[0];
                using (ExcelPackage newPackage = new ExcelPackage("dst.xlsx"))
                {
                    newPackage.Workbook.Worksheets.Add("newSht", copiedSht);
                    newPackage.Save();
                }
            }

dst.xlsx
src1.xlsx
src2.xlsx

@minren118 minren118 added the bug Something isn't working label Nov 1, 2024
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

1 participant