Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

c# - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...