简体   繁体   中英

How can we create, write and read an excel file for Windows Phone 8

I have created the file and written some data on it. When I look for created file in windows explorer it is not present. On the other side am not able to relate with the path of the file which I get on emulator. This is the link am using. Kindly help.

http://www.codeproject.com/Articles/33850/Generate-Excel-files-without-using-Microsoft-Excel?fid=1536838&df=90&mpp=10&noise=1&prof=True&sort=Position&view=Expanded&spc=None&fr=11#xx0xx

WP8 supports opening up office in read-only mode with your files. In order to do that you'll need to activate Excel's app2app file extension. The excel office app is registered to the XLS and XLSX file extensions.

To send Office files you'll first need write the complete file into Isolated Storage. Once the file is in IsolatedStorage send it over to office by using Launcher.LaunchFileAsync() .

    private async void LaunchExcel(object sender, RoutedEventArgs e)
    {
        var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("myExcelFile.xlsx");
        using (var s = await file.OpenAsync(FileAccessMode.ReadWrite))
        using (var dw = new DataWriter(s))
        {
            dw.WriteString("hello world");
        }

        await Launcher.LaunchFileAsync(
            await ApplicationData.Current.LocalFolder.GetFileAsync("myExcelFile.xlsx"));
    }

I'm not sure if the XLS format the article you linked to is actually supported by office on WP8. If it's not consider using the ClosedXML OSS project to generate an XLSX office open XML @ http://closedxml.codeplex.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM