mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
add special case for numeric type cells with a date number format
This commit is contained in:
parent
4c2c7a5859
commit
751599b44c
@ -427,6 +427,10 @@ PYBIND11_MODULE(lib, m)
|
|||||||
.def("column", [](xlnt::cell &cell)
|
.def("column", [](xlnt::cell &cell)
|
||||||
{
|
{
|
||||||
return cell.column().index;
|
return cell.column().index;
|
||||||
|
})
|
||||||
|
.def("format_is_date", [](xlnt::cell &cell)
|
||||||
|
{
|
||||||
|
return cell.has_format() && cell.number_format().is_date_format();
|
||||||
});
|
});
|
||||||
|
|
||||||
pybind11::enum_<xlnt::cell::type>(cell, "Type")
|
pybind11::enum_<xlnt::cell::type>(cell, "Type")
|
||||||
|
@ -63,7 +63,10 @@ def xlsx2arrow(io, sheetname):
|
|||||||
continue
|
continue
|
||||||
elif cell.row() == 2:
|
elif cell.row() == 2:
|
||||||
column_name = column_names[cell.column() - 1]
|
column_name = column_names[cell.column() - 1]
|
||||||
fields.append(pa.field(column_name, COLUMN_TYPE_FIELD[type]()))
|
if type == xpa.Cell.Type.Number and cell.format_is_date():
|
||||||
|
fields.append(pa.field(column_name, pa.date32))
|
||||||
|
else:
|
||||||
|
fields.append(pa.field(column_name, COLUMN_TYPE_FIELD[type]()))
|
||||||
first_batch.append(cell_to_pyarrow_array(cell, fields[-1].type))
|
first_batch.append(cell_to_pyarrow_array(cell, fields[-1].type))
|
||||||
if cell.column() == max_column:
|
if cell.column() == max_column:
|
||||||
schema = pa.schema(fields)
|
schema = pa.schema(fields)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user