We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem opening .xlsm Excel macro file using XlsIO UWP

Thread ID:

Created:

Updated:

Platform:

Replies:

127861 Dec 14,2016 11:01 AM UTC Dec 21,2016 12:04 PM UTC UWP 3
loading
Tags: XlsIO
Kasper Mathiesen
Asked On December 14, 2016 11:01 AM UTC

Hello

Thanks for a great product.

Im having trouble opening a excel file with macro in a UWP app.

My code looks like this:

using (ExcelEngine excelEngine = new ExcelEngine())
            {
                excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2016;
                IApplication application = excelEngine.Excel;

                try
                {
                    var uri = new Uri("ms-appx:///Docs/Cert.xlsm");
                    var cert = await StorageFile.GetFileFromApplicationUriAsync(uri);
                    application.SkipOnSave = SkipExtRecords.None;
                    application.SkipOnSave = SkipExtRecords.CopySubstreams;
                    Stream stream = await cert.OpenStreamForReadAsync();
                    IWorkbook workbook = await excelEngine.Excel.Workbooks.OpenAsync(stream, ExcelOpenType.Automatic);
                    IWorksheet worksheet = workbook.Worksheets[0];
                    worksheet.Range["B2"].Text = OrderNr;
                    //worksheet.Range["E6"].Text = Kunde;
                    worksheet.Range["B5"].Text = Skib;
                    #region Save the Workbook
                    StorageFile storageFile;
                    storageFile = await suscces.CreateFileAsync(OrderNr + " MV" + Skib + " Certificates.xlsm", CreationCollisionOption.ReplaceExisting);
                    if (storageFile != null)
                    {
                        //Saving the workbook
                        await workbook.SaveAsAsync(storageFile);
                        workbook.Close();
                    }
                    #endregion
                }
                catch (Exception)
                {

                }


            }

It fails on IWorkbook workbook = await excelEngine.Excel.Workbooks.OpenAsync(stream, ExcelOpenType.Automatic);

If I change the file to an xlsx excel file without macros it works no problem. 

I cant find anywhere that xlsm should not be included in the UWP version.

Thanks.


Sridhar Sukumar [Syncfusion]
Replied On December 15, 2016 12:29 PM UTC

Hi Kasper, 

 

Thank you for contacting Syncfusion support. 

 

We are unable to reproduce the issue from our side. We have shared a simple sample for your reference.  which can be downloaded from following location. 

 

Sample link:  

http://www.syncfusion.com/downloads/support/directtrac/general/ze/App3723382377.zip 

 

Kindly modify the sample to reproduce the issue and share us the modified sample along with the issue reproducing input files which will be helpful for us to give you a prompt solution at the earliest. 

 

Please let us know if you have any concerns. 

 

Regards, 

Sridhar S. 

Kasper Mathiesen
Replied On December 20, 2016 10:03 AM UTC

Hello Sridhar

Thank you for your reply I have downloaded the sample file and can confirm that it works as it should with the Sample.xlsm.

How ever if i try inputting my xlsm fil it gives the following exceptions:

Exception thrown: 'System.Exception' in mscorlib.ni.dll
Exception thrown: 'System.Exception' in mscorlib.ni.dll
Exception thrown: 'System.AggregateException' in mscorlib.ni.dll

It is a big Excel file with multiple tabs and macros, so that might be the cause.

Sridhar Sukumar [Syncfusion]
Replied On December 21, 2016 12:04 PM UTC

Hi Kasper, 
 
Thank you for updating us. 
 
We also suspect that the issue might be raised from your input file. So, we kindly request you to share the Excel document along with complete stack trace of the exception which will be helpful for us to give you a prompt solution at earliest. 
 
Note: We use the shared document only for validation purpose. We will delete the document after completing the validation. 
 
Regards, 
Sridhar S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;