mirror of
https://github.com/redstrate/Physis.git
synced 2025-07-05 01:57:45 +00:00
Handle multiple string columns when writing
This commit is contained in:
parent
8a3e8dad64
commit
76120b2dd0
1 changed files with 6 additions and 3 deletions
|
@ -123,8 +123,9 @@ pub fn write_rows(rows: &Vec<ExcelRow>, exh: &EXH) -> BinResult<()> {
|
||||||
// we need to sort them by offset
|
// we need to sort them by offset
|
||||||
column_definitions.sort_by(|(a, _), (b, _)| a.offset.cmp(&b.offset));
|
column_definitions.sort_by(|(a, _), (b, _)| a.offset.cmp(&b.offset));
|
||||||
|
|
||||||
|
let mut strings_len = 0;
|
||||||
for (definition, column) in &column_definitions {
|
for (definition, column) in &column_definitions {
|
||||||
EXD::write_column(writer, column, definition);
|
EXD::write_column(writer, column, definition, &mut strings_len);
|
||||||
|
|
||||||
// TODO: temporary workaround until i can figure out why it has 4 extra bytes in test_write's case
|
// TODO: temporary workaround until i can figure out why it has 4 extra bytes in test_write's case
|
||||||
if definition.data_type == ColumnDataType::Int8 && column_definitions.len() == 1
|
if definition.data_type == ColumnDataType::Int8 && column_definitions.len() == 1
|
||||||
|
@ -315,11 +316,13 @@ impl EXD {
|
||||||
cursor: &mut T,
|
cursor: &mut T,
|
||||||
column: &ColumnData,
|
column: &ColumnData,
|
||||||
column_definition: &ExcelColumnDefinition,
|
column_definition: &ExcelColumnDefinition,
|
||||||
|
strings_len: &mut u32,
|
||||||
) {
|
) {
|
||||||
match column {
|
match column {
|
||||||
ColumnData::String(_) => {
|
ColumnData::String(val) => {
|
||||||
let string_offset = 0u32; // TODO, but 0 is fine for single string column data
|
let string_offset = *strings_len;
|
||||||
Self::write_data_raw(cursor, &string_offset);
|
Self::write_data_raw(cursor, &string_offset);
|
||||||
|
*strings_len += val.len() as u32 + 1;
|
||||||
}
|
}
|
||||||
ColumnData::Bool(_) => match column_definition.data_type {
|
ColumnData::Bool(_) => match column_definition.data_type {
|
||||||
ColumnDataType::Bool => todo!(),
|
ColumnDataType::Bool => todo!(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue