Parse Excel to JSON

2019-05-07 20:05发布

I would like to know if is posible parse a excel to json. And if is possible which is the structure of the excel to make it possible. There is an application or something??

I have this JSON sructure http://pastie.org/2760828 And I have to insert 500 products and i would like insert into excel and parse them.

2条回答
冷血范
2楼-- · 2019-05-07 20:24

You can do it like this:
1) First convert your excelsheet to datatable
2) And then convert your datatable to json like below:

1) conversion excel sheet to datatable

string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=G:\school pro\schools3.xlsx;
Extended Properties=Excel 5.0";

StringBuilder stbQuery = new StringBuilder();
stbQuery.Append("SELECT top 10 * FROM [A1:M98]");
OleDbDataAdapter adp = new OleDbDataAdapter(stbQuery.ToString(), ConnectionString);

DataTable dtSchools = new DataTable();
adp.Fill(dtSchools);

2) conversion datatable to json

Newtonsoft.Json.JsonConvert.SerializeObject(dtSchools)
查看更多
Luminary・发光体
3楼-- · 2019-05-07 20:29

ExcelToJSON will convert an Excel sheet to JSON format

http://www.exceltojson.com/

查看更多
登录 后发表回答