1 Star 4 Fork -1

hibo/json-excel-convert

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo-make-json-data.py 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
生成JSON数据
"""
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import json
sheet = {
'type': 'sheet',
'data': {
'name': 'sheet名称',
'width': 20,
'height': 20,
'description': [
'测试说明1',
'测试说明2',
'测试说明3'
],
'column': [
{
'field': 'id',
'edit': False,
'name': '数据编号(数字)',
'description': '不可编辑',
'example': ''
}
]
}
}
for i in xrange(1):
sheet['data']['column'].append({
'field': 'field%d' % i,
'edit': True,
'name': '编号编号编号编号编号编号编号编号编号编号编号%d(多选)' % i,
'description': '可选值:\n101: 选项1\n102: 选项2\n103: 选项3'*10,
'example': '101,102'
})
with open('JsonToExcel.json', 'w') as fp:
for i in xrange(1):
sheet['data']['name'] = '测试工作簿%d' % i
sheet_str = json.dumps(sheet)
fp.write(sheet_str)
fp.write('\n')
# 加入测试数据10
for j in xrange(10):
row = {
'type': 'row',
'data': {
'id': j
}
}
for k in xrange(19):
row['data']['field%d' % k] = '\'value-%d-%d' % (j, k)
fp.write(json.dumps(row))
fp.write('\n')
print 'ok'
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/aibow/json-excel-convert.git
git@gitee.com:aibow/json-excel-convert.git
aibow
json-excel-convert
json-excel-convert
master

搜索帮助