This project has moved. For the latest updates, please go here.

CopyTo one to another workbook style error

Nov 10, 2014 at 9:03 AM
System.Collections.Generic.KeyNotFoundException
mscorlib.dll!System.Collections.Generic.Dictionary<int,System.__Canon>.this[int].get(int key) + 0x8a 
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.GetStyleById(int id)
System.Core.dll!System.Linq.Enumerable.WhereSelectEnumerableIterator<int,System.__Canon>.MoveNext() + 0xc8
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.GenerateWorkbookStylesPartContent(DocumentFormat.OpenXml.Packaging.WorkbookStylesPart workbookStylesPart, ClosedXML.Excel.XLWorkbook.SaveContext context) 行 2443 + 0x8ae 
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.CreateParts(DocumentFormat.OpenXml.Packaging.SpreadsheetDocument document) 行 139 + 0x1a
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.CreatePackage(string filePath, DocumentFormat.OpenXml.SpreadsheetDocumentType spreadsheetDocumentType)  + 0x10
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.SaveAs(string file) + 0x36 

internal IXLStyle GetStyleById(Int32 id)
    {
        return _stylesById[id];
    }
Nov 10, 2014 at 9:04 AM
namespace Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var d1 = new XLWorkbook("Server.xlsx"))
            {
                using (var ms = new MemoryStream())
                {
                    using (var d2 = new XLWorkbook())
                    {
                        //spell_template
                        //wheel_progressive_template
                        //worn_weapon_seal_template
                        d1.Worksheet("wheel_progressive_template").CopyTo(d2, "wheel_progressive_template");
                        d2.SaveAs("Data2.xlsx");
                        //d2.SaveAs(ms);
                    }
                }
            }
        }
    }
}
Nov 10, 2014 at 9:20 AM
Edited Nov 10, 2014 at 9:20 AM
Coordinator
Nov 10, 2014 at 5:53 PM
I can't download the file. I think it's asking me to register before I can download it. Please provide a direct link to the file or something easier.
Nov 11, 2014 at 12:45 AM
MDeLeon wrote:
I can't download the file. I think it's asking me to register before I can download it. Please provide a direct link to the file or something easier.
MDeLeon,Thank u for your replay to me! I re-upload the file! click here to download
Coordinator
Nov 11, 2014 at 5:10 PM
Still can't download it. Create an issue and attach the file.
Nov 12, 2014 at 1:30 AM
Edited Nov 12, 2014 at 1:30 AM
MDeLeon wrote:
Still can't download it. Create an issue and attach the file.
Thanks. I create an issueshttps://closedxml.codeplex.com/workitem/9389