[UWP]如何在UWP c#windows 10中的SQLite数据库中添加/导入Excel(xls)文件数据? [英] [UWP]How to add/import Excel(xls) file data in SQLite database in UWP c# windows 10?

查看:140
本文介绍了[UWP]如何在UWP c#windows 10中的SQLite数据库中添加/导入Excel(xls)文件数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我是UWP c#windows 10应用程序的新手。我想在sqlite数据库中导入excel数据。 

I am new to work on UWP c# windows 10 application. I want to import the excel data in sqlite database. 

我已经在xaml中编写了uploader的代码,(下面这段代码给我的文件从文件浏览器中选择后的名称)

I have written the code for uploader in xaml,(thhis below code give me the file name after selecting from file browser)

FileOpenPicker openPicker = new FileOpenPicker();

openPicker.ViewMode = PickerViewMode.Thumbnail;

openPicker.FileTypeFilter.Add(" .csv");

openPicker.FileTypeFilter.Add(" .xls");

openPicker.FileTypeFilter.Add(" .xlsx");

StorageFile file = await openPicker.PickSingleFileAsync();

if(file!= null)

{

  uplodelabel.Text ="所选文件:" + file.Name;

}

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.FileTypeFilter.Add(".csv");
openPicker.FileTypeFilter.Add(".xls");
openPicker.FileTypeFilter.Add(".xlsx");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
 uplodelabel.Text = "Selected file:" + file.Name;
}

现在我如何读取所选文件并在sqlite中导入数据数据库表?

Now how I can read that selected file and import the data in sqlite database table?

请指导我或提供任何示例代码。

Please guide me or give any sample code.

问候,

Ashwin

Regards,
Ashwin

推荐答案

您好,
目前,没有可用于直接从excel文件读取数据的内置API。但是在UWP应用程序中还有其他一些方法可以做到这一点。

Open XML SDK 其中一个。 Open XML SDK提供了使用Office Word,Excel和PowerPoint文档的工具。它可以从Excel文档中提取数据。您可以在此处看到该文档:
欢迎使用Open XML SDK 2.5 for Office

此外,还有一些第三方库,你可以打开搜索引擎并从Syncfusion中寻找工具。

对于csv文件,您可以参考此博客来解析csv文件:现代应用程序 - 解析CSV UWP应用程序中的文件

最好的问候,

Roy
Hi,
Currently, there is no build-in API that could be used to read data from excel file directly. But there are some other ways to do that in UWP apps.
Open XML SDK in one of them. The Open XML SDK provides tools for working with Office Word, Excel, and PowerPoint documents. It could extraction of data from Excel documents.You could see the document here: Welcome to the Open XML SDK 2.5 for Office.
Also, there are some thrid party libraries that could that, you could open your search engine and look for tools from Syncfusion.
For csv files, you could refer this blog to parse csv files:Modern Apps - Parsing CSV Files in UWP Apps
Best regards,
Roy


这篇关于[UWP]如何在UWP c#windows 10中的SQLite数据库中添加/导入Excel(xls)文件数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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