XlsIO can't open this file Excel et.

System.ArgumentException: Item has already been added. Key in dictionary: ' ' Key being added: '&'

   at System.Collections.SortedList.Add(Object key, Object value)

   at Syncfusion.XlsIO.Implementation.FormulaUtil.FillDefaultOperations()

   at Syncfusion.XlsIO.Implementation.FormulaUtil..ctor(IApplication application, Object parent, NumberFormatInfo numberFormat, Char chArgumentsSeparator, Char chRowSeparator)

   at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser..ctor(WorkbookImpl book)

   at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.get_Parser()

   at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseContentType()

   at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseDocument(List`1& themeColors, Boolean parseOnDemand)

   at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseExcel2007Stream(Stream stream, String password, Boolean parseOnDemand)

   at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseStream(Stream stream, String password, ExcelVersion version, ExcelParseOptions options)

   at Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, Stream stream, ExcelParseOptions options, ExcelVersion version)

   at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, Stream stream, ExcelVersion version, ExcelParseOptions options)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version, ExcelParseOptions options)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelOpenType openType)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream)

   at WebApplication1.Controllers.ValuesController.Get(Int32 id) in C:\Users\Ment\Desktop\WebApplication1\WebApplication1\Controllers\ValuesController.cs:line 34

   at lambda_method4(Closure , Object , Object[] )

   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)

   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)

   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)

   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)


Attachment: test_1880b4c8.rar

9 Replies 1 reply marked as answer

PA panupong August 7, 2021 09:05 AM UTC

This is my code 

            using (ExcelEngine excelEngine = new ExcelEngine())

            {

                IApplication application = excelEngine.Excel;

                FileStream excelStream = new FileStream(@"D:\test.xlsx", FileMode.Open, FileAccess.Read);

                IWorkbook workbook = application.Workbooks.Open(excelStream);


                //Initialize XlsIO renderer.

                XlsIORenderer renderer = new XlsIORenderer();


                //Convert Excel document into PDF document

                PdfDocument pdfDocument = renderer.ConvertToPDF(workbook);


                Stream stream = new FileStream("ExcelToPDF.pdf", FileMode.Create, FileAccess.ReadWrite);

                pdfDocument.Save(stream);


                excelStream.Dispose();

                stream.Dispose();

            }



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team August 9, 2021 10:40 AM UTC

Hi Panupong, 

Greetings from Syncfusion. 

We are unable to reproduce the reported issue at our end. The sample which we have tried at our end can be downloaded from the below link. 


We have shared the output PDF document in project folder for your reference. We have checked the issue in 19.2.0.44 version of Syncfusion XlsIO. 

Kindly confirm the Syncfusion XlsIO version you are using at your end and share us the issue reproducing sample which will be helpful for us in investigating the query. 

Regards, 
Keerthi. 



PA panupong August 10, 2021 03:49 AM UTC

I Using . target framework

net 5 is not .net core 2

And I using Syncfusion XlsIO 19.2.0.44

And In my code I share Project


Attachment: apiApplication3_97c24dc7.rar


Please  ask me as soon 



Marked as answer

PA panupong August 10, 2021 04:36 AM UTC

I Using . target framework

net 5 is not .net core 2

And I using Syncfusion XlsIO 19.2.0.44

And In my code I share Project

This is my project https://drive.google.com/file/d/1rsKdFUc8ENLMnJkaxMhV3FWtTJmeHKLU/view?usp=sharing

Please  ask me as soon


Attachment: test_e23f773c.rar


PA panupong August 10, 2021 05:36 AM UTC



This Bug line 38 


And this .net 5 is not .net core 2.0






KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team August 10, 2021 08:00 AM UTC

Hi Panupong, 

Thanks for the update. 

We are unable to reproduce the reported issue at our end. We have executed the sample in .NET 5.0 latest SDK version 5.0.8. Please look into the following video screenshot. 


Kindly check the sample in latest .NET 5.0 SDK and let us know the status. 

Regards, 
Keerthi. 



PA panupong replied to Konduru Keerthi Konduru Ravichandra Raju August 10, 2021 08:20 AM UTC

I using .net 5.0.302 SDK And .net Runtime 5.0.8

Please  ask me as soon



PA panupong replied to Konduru Keerthi Konduru Ravichandra Raju August 10, 2021 08:37 AM UTC

Please look into the following video . 



Attachment: bandicam_20210810_152525114_8fb792d1.rar


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team August 11, 2021 10:36 AM UTC

Hi Panupong, 

We have created a new support incident under your direct-trac account and request you to follow that for further updates regarding this query. 

Regards, 
Keerthi. 


Loader.
Up arrow icon