我们如何为 Windows Phone 8 创建、写入和读取 Excel 文件 [英] How can we create, write and read an excel file for Windows Phone 8

查看:17
本文介绍了我们如何为 Windows Phone 8 创建、写入和读取 Excel 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了该文件并在其上写入了一些数据.当我在 Windows 资源管理器中查找创建的文件时,它不存在.另一方面,我无法与我在模拟器上获得的文件路径相关联.这是我使用的链接.请帮忙.

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 支持以只读模式打开办公室文件.为此,您需要激活 Excel 的 app2app 文件扩展名.Excel Office 应用程序已注册到 XLS 和 XLSX 文件扩展名.

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.

要发送 Office 文件,您首先需要将完整文件写入独立存储.一旦文件位于隔离存储中,使用 Launcher.LaunchFileAsync() 将其发送到办公室.

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"));
    }

我不确定 WP8 上的 office 是否真正支持您链接到的文章的 XLS 格式.如果不考虑使用ClosedXML OSS项目生成XLSX office open XML@http://closedxml.codeplex.com/

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/

这篇关于我们如何为 Windows Phone 8 创建、写入和读取 Excel 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆