跳转到主要内容

Excel 存储库

项目描述

excel-storage

Excel 存储库

安装

pip install excel-storage

用法

from excel_storage import ExcelStorage

def excelfunc():
    data = [
        {
            'Column 1': 1,
            'Column 2': 2,
        },
        {
            'Column 1': 3,
            'Column 2': 4,
        }
    ]
    fpath = ExcelStorage(data, 'my_data', font='name SimSum').save()

from excel_storage import ExcelStorage

def excelfunc():
    data = [
        ['Column 1', 'Column 2'],
        [1, 2],
        [3, 4]
    ]
    fpath = ExcelStorage(data, 'my_data', font='name SimSum').save()

from excel_storage import ExcelStorage

def excelfunc():
    data = [
        ['Column 1', 'Column 2'],
        [1, [2, 3]],
        [3, 4]
    ]
    fpath = ExcelStorage(data, 'my_data', font='name SimSum', merge_type='row_merge').save()

from excel_storage import ExcelStorage

def excelfunc():
    headers = ['Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5']
    data = [['Value 1', [['Value 2 Row 1', [['Value 3', 'Value 4', [['Value 5']]]]], ['Value 2 Row 2', [['Value 3 Row 1', 'Value 4 Row 1', [['Value 5 Row 1']]], ['Value 3 Row 2', 'Value 4 Row 2', [['Value 5 Row 2']]]]]]]]
    fpath = ExcelStorage(data, 'my_data', font='name SimSum', merge_type='list_row_merge', headers=headers).save()

from excel_storage import ExcelStorage

def excelfunc():
    headers = ['Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5']
    mapping = {
        'field_key': 'Column 1',
        'data_key': 'Children 1',
        'next': {
            'field_key': 'Column 2',
            'data_key': 'Children 2',
            'next': {
                'field_key': ['Column 3', 'Column 4'],
                'data_key': 'Children 3',
                'next': {
                    'field_key': 'Column 5',
                }
            }
        }
    }
    data = [{
        'Column 1': 'Value 1',
        'Column 11': 'Value 11',
        'Children 1': [{
            'Column 2': 'Value 2 Row 1',
            'Column 22': 'Value 22 Row 1',
            'Children 2': [{
                'Column 3': 'Value 3',
                'Column 4': 'Value 4',
                'Children 3': {
                    'Column 5': 'Value 5',
                }
            }]
        }, {
            'Column 2': 'Value 2 Row 2',
            'Column 22': 'Value 22 Row 2',
            'Children 2': [{
                'Column 3': 'Value 3 Row 1',
                'Column 4': 'Value 4 Row 1',
                'Children 3': {
                    'Column 5': 'Value 5 Row 1',
                }
            }, {
                'Column 3': 'Value 3 Row 2',
                'Column 4': 'Value 4 Row 2',
                'Children 3': {
                    'Column 5': 'Value 5 Row 2',
                }
            }]
        }]
    }]
    fpath = ExcelStorage(data, 'my_data', font='name SimSum', merge_type='dict_row_merge', mapping=mapping, headers=headers).save()

参数

  • font='name SimSum'
    • 设置字体为SimSum(宋体)
  • force_csv=True
    • CSV格式?True为是,False为否,默认为False

CSV

datas = [
    [u'中文', ]
]
Win Excel 2013 Mac Excel 2011 Mac Excel 2016 Mac Numbers
UTF8 乱码 乱码 乱码 正常
GB18030 正常 正常 正常 乱码
UTF8 + BOM_UTF8 正常 乱码 正常 正常
UTF16LE + BOM

项目详细信息


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

excel-storage-1.0.4.tar.gz (4.6 kB 查看哈希)

上传时间:

构建分布

excel_storage-1.0.4-py2.py3-none-any.whl (4.1 kB 查看散列值)

上传时间: Python 2 Python 3

由以下支持