neil3d / excel2json Goto Github PK
View Code? Open in Web Editor NEW把Excel表转换成json对象,并保存到一个文本文件中。
Home Page: https://neil3d.github.io
License: MIT License
把Excel表转换成json对象,并保存到一个文本文件中。
Home Page: https://neil3d.github.io
License: MIT License
例如excel表内容目前导出是这样:
{
"1": {
"ID": 1,
"name": "铜钱",
"info": "",
"type": 1,
"iconID": 1,
"1": "1"
},
"2": {
"ID": 2,
"name": "元宝",
"info": "暂略",
"type": 0.0,
"iconID": 2,
"2": "2"
},
"3": {
"ID": 3,
"name": "测试武器",
"info": "暂略",
"type": 0.0,
"iconID": 0.0,
"3": "3"
}
}
我希望空数据不要导出来,导出这样的:
{
"1": {
"ID": 1,
"name": "铜钱",
"type": 1,
"iconID": 1,
"1": "1"
},
"2": {
"ID": 2,
"name": "元宝",
"info": "暂略",
"iconID": 2,
"2": "2"
},
"3": {
"ID": 3,
"name": "测试武器",
"info": "暂略",
"3": "3"
}
}
例如表格是
ids typs name
1 1 111
2 1 222
3 2 333
4 2 444
转成json:
第一种
1{
1{
name:111
},
2{
name:222
}
}
或者
1_1{
name:111
},
1_2:
{
name :222
}
这样就更爽了。。有的表需要双重定位。。需求还蛮多的。。
我转了一个excel,我的第一行数据没有转成json而是直接被丢弃了…………
wtf!
以下是序列化的结果
{
"1": {
"id": 1,
"name": "Apple_G",
"scrores": 3
},
"2": {
"id": 2,
"name": "Apple_R",
"scrores": 4
}
}
以下是想要序列化的结果
[
{
"id": 1.0,
"name": "Apple_G",
"scrores": 3.0
},
{
"id": 2.0,
"name": "Apple_R",
"scrores": 4.0
}
]
最新版去掉了这个功能
1.1.1和1.1.0源码检测有特洛伊
转化结果
{
{
"id":1,
"tags":"["player","enemy"]"
}
}
希望结果
{
{
"id":1,
"tags":["player","enemy"]
}
}
比如:表中配置多个,相同关卡数据,相同关卡下面有不同的小关卡,不能见这些小关卡折叠同一个大关卡下
一个文件多个Sheet 能不能添加一个设置选项.
1是现在的情况所有sheet在同一个json中:{ SheetName: { SheetOBject } }
2是每个sheet单独导出一个json
😘
如果实在不行,也可以在展示文字的css样式下加一个 white-space: pre-wrap;
也行。
疑似因为 Program.Options.cs 中 cell_json,all_string 与 lowcase 3个命令的缩写 都是 'l' 导致的冲突;
当命令行使用 -cell_json true 参数时,运行结果 变成全是字符串了
GUI 运行无此问题,恳请尽快修复
Win7下面的GUI
目前只能导出 int,data,string。。 但我[1,2,3]数组导出的时候就变字符串了
不支持多个sheet???
有Bug还是用1.4.2好
比如有列数据:
Date_Begin
开启日期
2018/06/05
那么这个日期在object value = row[column];读出来的时候就变成了{2018/6/5 0:00:00}
我不想要后面的时间,我只想要日期,请问要怎么处理呢?
发现当前版本 v1.4 ~ 1.4.3 的处理都是若有未填的格子时:
string 类型自动填为 "" (0长度字符串), number类型自动填为 0.0 , boolean 类型自动填为 false
建议规则改为,若有未填的格子时,无论指定是什么类型,都不如直接 剃除这对 key-value 项。
这样至少有两个明显好处:
1 若是不用这些格数据,可以故意不填,这样处理可以明显减少json文件的尺寸
2 便于使用者自己实现默认值功能,等于是用 undefined作为默认值标记——可以故意不填一些格子,运行时可以代码检测读到的值是否 undefined 然后替换成自己约定的指定默认值
"id": 10001, "name": "手枪", "weaponType": "pistol", "system": "reality", "icon": "", "ATT": 1, "attackSpeed": 1, "attackRange": "直线", "distance": 1000, "clip": 15, "recoil": 0, "Column11": "", "Column12": "", "Column13": "", "Column14": "", "Column15": "", "Column16": "", "Column17": "", "Column18": "", "Column19": "", "Column20": "", "Column21": "", "Column22": "", "Column23": "", "Column24": "", "Column25": "", "Column26": "", "Column27": ""
查看了下是Excel库读sheet取到了200多行,27列,
以前使用int来标记该列的文本以数字的形式处理,string标记该列的文本是字符串,同时如果是json格式的字符串也可以额外处理。
但是经过测试发现,至少从1.4.2开始,这个标记应该已经无效了,实际是以具体的文本为导向了。
个人以为还是加个判断为好,优先已字段标记,对于可能是json的字符串直接以‘json’标记。
不好意思,我是新手程序猿,新手git使用者
在Mac电脑上使用命令运行 mono ./excel2json.exe 程序运行不起来会报错
下面是报错信息
Launch excel2json GUI Mode...
WARNING: The Carbon driver has not been ported to 64bits, and very few parts of Windows.Forms will work properly, or at all
System.EntryPointNotFoundException: GetWindowPort
at (wrapper managed-to-native) System.Drawing.MacSupport.GetWindowPort(intptr)
at System.Drawing.MacSupport.GetCGContextForView (System.IntPtr handle) [0x0007f] in <7beee3dcb66f4c2a8953ef8a786c2e63>:0
at System.Drawing.Graphics.FromHwnd (System.IntPtr hwnd) [0x00042] in <7beee3dcb66f4c2a8953ef8a786c2e63>:0
at System.Windows.Forms.Control.CreateGraphics () [0x00019] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control.CreateGraphics()
at System.Windows.Forms.Document.owner_HandleCreated (System.Object sender, System.EventArgs e) [0x00000] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.OnHandleCreated (System.EventArgs e) [0x00019] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.TextBoxBase.OnHandleCreated (System.EventArgs e) [0x00000] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.TextBox.OnHandleCreated (System.EventArgs e) [0x00000] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.WmCreate (System.Windows.Forms.Message& m) [0x00000] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x0021c] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.TextBoxBase.WndProc (System.Windows.Forms.Message& m) [0x001c5] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.TextBox.WndProc (System.Windows.Forms.Message& m) [0x0011c] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x0000b] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.NativeWindow.WndProc (System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam) [0x00085] in <556a6ba2c0a546f1ad2318c309ce0945>:0
Unhandled Exception:
System.EntryPointNotFoundException: GetWindowPort
at (wrapper managed-to-native) System.Drawing.MacSupport.GetWindowPort(intptr)
at System.Drawing.MacSupport.GetCGContextForView (System.IntPtr handle) [0x0007f] in <7beee3dcb66f4c2a8953ef8a786c2e63>:0
at System.Drawing.Graphics.FromHwnd (System.IntPtr hwnd) [0x00042] in <7beee3dcb66f4c2a8953ef8a786c2e63>:0
at System.Windows.Forms.Control.CreateGraphics () [0x00019] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control.CreateGraphics()
at System.Windows.Forms.Document.owner_VisibleChanged (System.Object sender, System.EventArgs e) [0x0000d] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.OnVisibleChanged (System.EventArgs e) [0x0002f] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.ChangeParent (System.Windows.Forms.Control new_parent) [0x000c7] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control.ChangeParent(System.Windows.Forms.Control)
at System.Windows.Forms.Control+ControlCollection.RemoveImplicit (System.Windows.Forms.Control control) [0x0003d] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.ComboBox.set_DropDownStyle (System.Windows.Forms.ComboBoxStyle value) [0x0008e] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.ComboBox.set_DropDownStyle(System.Windows.Forms.ComboBoxStyle)
at excel2json.GUI.MainForm.InitializeComponent () [0x00d58] in <39b8e811f05f487b9bd0f6841982eb18>:0
at excel2json.GUI.MainForm..ctor () [0x0003c] in <39b8e811f05f487b9bd0f6841982eb18>:0
at (wrapper remoting-invoke-with-check) excel2json.GUI.MainForm..ctor()
at excel2json.Program.Main (System.String[] args) [0x00019] in <39b8e811f05f487b9bd0f6841982eb18>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.EntryPointNotFoundException: GetWindowPort
at (wrapper managed-to-native) System.Drawing.MacSupport.GetWindowPort(intptr)
at System.Drawing.MacSupport.GetCGContextForView (System.IntPtr handle) [0x0007f] in <7beee3dcb66f4c2a8953ef8a786c2e63>:0
at System.Drawing.Graphics.FromHwnd (System.IntPtr hwnd) [0x00042] in <7beee3dcb66f4c2a8953ef8a786c2e63>:0
at System.Windows.Forms.Control.CreateGraphics () [0x00019] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control.CreateGraphics()
at System.Windows.Forms.Document.owner_VisibleChanged (System.Object sender, System.EventArgs e) [0x0000d] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.OnVisibleChanged (System.EventArgs e) [0x0002f] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.Control.ChangeParent (System.Windows.Forms.Control new_parent) [0x000c7] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control.ChangeParent(System.Windows.Forms.Control)
at System.Windows.Forms.Control+ControlCollection.RemoveImplicit (System.Windows.Forms.Control control) [0x0003d] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at System.Windows.Forms.ComboBox.set_DropDownStyle (System.Windows.Forms.ComboBoxStyle value) [0x0008e] in <556a6ba2c0a546f1ad2318c309ce0945>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.ComboBox.set_DropDownStyle(System.Windows.Forms.ComboBoxStyle)
at excel2json.GUI.MainForm.InitializeComponent () [0x00d58] in <39b8e811f05f487b9bd0f6841982eb18>:0
at excel2json.GUI.MainForm..ctor () [0x0003c] in <39b8e811f05f487b9bd0f6841982eb18>:0
没有图片上的导出SQL和C#实体类是没分享这部分功能吗?
mono ./excel2json.exe --excel test.xlsx --json test.json --header 3 --array true
报错:Error: Object reference not set to an instance of an object
看了下源码,原因貌似是Program.Options.cs 这个文件中 两个相邻的Option参数cell_json 与 all_string 使用了同一字符 "l",导致严格匹配后将cell_json的值给到了all_string 导致参数值错误
测试将Option 参数cell_json 的字符改成其他 字符 visual studio 重新编译生成后 不再出现此问题
① 能否增加配置用的 Json 或 xml 文件,该文件中保存了当前表格的读取路径、保存路径,每张表和一个配置文件建立关联、不用每次保存时都手动选择保存路径
② 能否增加以模板文件来生成C#代码能功能呢?譬如想用到自定义类型,但需要命名空间,每生成一次都要手动添加命名空间很麻烦。
③ 可否支持自定义类型
④ 可否支持批量导入
这个issue里的中文也能看到问题。。。 当然复制出来是好的
请问下是否可以通过某个字段进行分组生成头行结构的json呢?
看到修了一个导出的json数据带有错误项的bug,能否请可以编译的同学更新一下binary?
得到的json
{ "3": { "ID": 3, "Name": "阳", "CharacterStruct": "LR", "Component1": "左耳刀", "Component2": "日", "Type": "Normal", "Function1": "", "Function2": "" }, "4": { "ID": 4, "Name": "石", "CharacterStruct": "None", "Component1": "", "Component2": "", "Type": "Normal", "Function1": "", "Function2": "" }, "5": { "ID": 5, "Name": "卒", "CharacterStruct": "None", "Component1": "", "Component2": "", "Type": "Normal", "Function1": "", "Function2": "" },......
`@SET EXCEL_FOLDER=.\excel
@set JSON_FOLDER=.\json
@set EXE=.\excel2json.exe
@echo Converting excel files in folder %EXCEL_FOLDER% ...
for /f "delims=" %%i in ('dir /b /a-d /s %EXCEL_FOLDER%*.xlsx') do (
@echo processing %%~nxi
@call %EXE% --excel %EXCEL_FOLDER%%%~nxi --json %JSON_FOLDER%%%~ni.json --header 3
)`
我发现GUI工具更改ExportType为array 就可以了 但是bat 中的命令没有看到
比如实际数据只有5条,实际导出的数组长度可能是500,剩下495条都是空数据,有字段,但是值都是默认值
是不是应该为“”?
转换中,“\”会重复输出成两个“\”
比如想选取第一列,第三列,排除第二列,需要怎么做呢?
因为同一张表,策划在配置的时候,有些字段是服务器端用到的,有些字段是客户端用到的。不需要用到的字段,不希望生成到文件中去。这个需求要怎么实现?
有个别的导出软件,就是命名!开头的Sheet,不导出。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.