Skip to content

Open one workbook and CopyTo Some worksheet to new workbook, the worksheet format damge, for example, merge cell all unmerger. #2448

@luzwales

Description

@luzwales

Read and complete the full issue template

string folder = "C:/CMF"; XLWorkbook workbook = new XLWorkbook(folder+"//Summary.xlsx"); IXLWorksheet worksheet = workbook.Worksheet(1); XLWorkbook newWorkbook = new XLWorkbook(); worksheet.CopyTo(newWorkbook,"Summary"); //Only copy sheet1 to new workbook and rename Summary, newWorkbook.SaveAs(folder+"/Report/Test.xlsx"); // And save this workbook as new file.

Do not randomly delete sections. They are here for a reason.
failure log:
`

error280880_01.xml

Errors were detected in file 'C:\CMF\Report\Test.xlsx' Removed Records: Named range from /xl/workbook.xml part (Workbook) Removed Records: Formula from /xl/worksheets/sheet1.xml part Removed Records: Formula from /xl/calcChain.xml part (Calculation properties) ` **Do you want to request a *feature* or report a *bug*?** - [x] Bug - [ ] Feature - [ ] Question

Did you test against the latest CI build?

  • Yes
  • No

If you answered No, please test with the latest development build first.

Version of ClosedXML
0.102.3 for latest revision.
e.g. 0.95.3

What is the current behavior?

Complete this.

What is the expected behavior or new feature?

Complete this.

Is this a regression from the previous version?

Regressions get higher priority. Test against the latest build of the previous minor version. For example, if you experience a problem on v0.95.3, check whether it the problem occurred in v0.94.2 too.

Reproducibility

This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.

Without a code sample, it is unlikely that your issue will get attention. Don't be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.

Code to reproduce problem:

public void Main()
{
    // Code standards:
    // - Fully runnable. I should be able to copy and paste this code into a 
    //   console application and run it without having to edit it much.
    // - Declare all your variables (this follows from the previous point)
    // - The code should be a minimal code sample to illustrate issue. The code 
    //   samples on the wiki are good examples of the terseness that I want. Don't
    //   post your full application.
}
  • I attached a sample spreadsheet. (You can drag files on to this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions