C1.Xaml.Excel for UWP

Posted by: li.yihua on 26 October 2017, 1:43 pm EST

  • Posted 26 October 2017, 1:43 pm EST


    I want to Open an template excel file from Asstets,

    Windows.Storage.StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
    StorageFolder tempFolder2 = await installedLocation.CreateFolderAsync("Assets", CreationCollisionOption.OpenIfExists);
    StorageFile file =await tempFolder2.CreateFileAsync("cgktemplate.xlsx", CreationCollisionOption.OpenIfExists);
    _book = new C1XLBook();
    await _book.LoadAsync(file, FileFormat.OpenXml); //It cannot working. trow an Exception. why?
  • Marked as Answer

    Replied 26 October 2017, 10:39 pm EST


    I tried using your code snippet and observed the following:
    1. Using
    Windows.Storage.StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
    threw an exception System.UnauthorizedAccessException: Access is denied.
    To resolve this, you may replace it with
    Windows.Storage.StorageFolder installedLocation =  ApplicationData.Current.LocalFolder;

    2. Using code snippet in point#1, an exception C1.C1Zip.ZipFileException:Central dir not found was thrown.
    To resolve this, try adding some content to XLSX file, before loading the same.

    I have uploaded a sample application for your reference, you may download the same using the following URL:https://www.dropbox.com/s/jqypxhre9ces9sl/prj_assetExcel.zip?dl=0

    Ruchir Agarwal
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels