brechtsanders / xlsxio

XLSX I/O - C library for reading and writing .xlsx files
MIT License
420 stars 112 forks source link

Add GObject Introspection support #96

Open taozuhong opened 3 years ago

taozuhong commented 3 years ago

Add GObject Introspection support to generate .gir file to support multi-program language

https://gi.readthedocs.io/en/latest/index.html

brechtsanders commented 3 years ago

I would need some help with that. Can you write a test scenario for this (e.g. in Python something that writes to a file and the reads it again)?

taozuhong commented 3 years ago

Here are two python examples for testing:

import xlsxio
xlsxio_reader = xlsxio.XlsxioReader('file.xlsx')
sheet = xlsxio_reader.get_sheet()
data = sheet.read_data()
sheet.close()
xlsxio_reader.close()

print(data)
import xlsxio
import datetime

types = [str, str, float, int, bool, datetime.datetime]
with xlsxio.XlsxioReader('file.xlsx') as reader:
    with reader.get_sheet('hello', types=types) as sheet:
        header = sheet.read_header()
        only_active = []
        for row in sheet.iter_rows():
            if row[4]:
                only_active.append(row)
print(only_active)

Example project with GObject introspection support: https://github.com/libical/libical/blob/master/CMakeLists.txt