MathNya / umya-spreadsheet

A pure rust library for reading and writing spreadsheet files
MIT License
238 stars 41 forks source link

Removed row styles are being applied to the above row after upgrading to 1.2.0 #181

Closed BharathIO closed 4 months ago

BharathIO commented 4 months ago

I have 2 rows in Excel.

Row 1 has different styles with default height. Row 2 has different styles with custom height as "118".

When I remove Row-2 from the workbook sheet, its row height "118" is applied to row-1. Please let me know if i am missing anything.

Note: It was working fine before upgrading to 1.2.0

Input Excel

Screenshot 2024-02-16 at 10 48 56 PM

lov-template-new.xlsx

Output Excel after removing row

Screenshot 2024-02-16 at 10 49 51 PM

1_style_issue_output.xlsx

Code

let template_path = "../lov-template-new.xlsx";
    let output_path = ../1_style_issue_output.xlsx";

let  mut book = match umya_spreadsheet::reader::xlsx::read(template_path) {
        Ok(book) => book,
        Err(e) => {
            println!("Error: {:?}", e);
            return;
        }
    };

if let Some(sheet) =  book.get_sheet_mut(&1) {
    let row_index = 2;
    sheet.remove_row(&row_index, &1);
    println!("Removed row: {}", row_index);
   }

match umya_spreadsheet::writer::xlsx::write(&book, output_path) {
        Ok(_) => println!("Success writing to file: {}", output_path),
        Err(e) => println!("Error: {:?}", e),
    };
MathNya commented 4 months ago

@BharathIO We have released 1.2.1 which fixes this problem. Please check it out.

BharathIO commented 4 months ago

Facing another issue after upgrading to 1.2.1. When I remove a row after creating a new row, all the data for the next and new rows is disappeared. Could you please check this breaking change?

Input file

employees-template_uploaded.xlsx

Output file

non_lov.xlsx

Code

    let template_path = "../employees-template_uploaded.xlsx";
    let output_path = "..//non_lov.xlsx";

    println!("Reading input template file: {:?}", template_path);
    let mut book = match umya_spreadsheet::reader::xlsx::read(template_path) {
        Ok(book) => book,
        Err(e) => {
            println!("Error: {:?}", e);
            return
        }
    };

    let shee1: &mut Worksheet = book.get_sheet_mut(&0).unwrap();

    let new_row_index = 4;

    shee1.insert_new_row(&new_row_index, &5);

    shee1.get_cell_mut((1, new_row_index)).set_value("123");

    let template_row_index = 3;

    shee1.remove_row(&template_row_index, &1);
    println!("Removed row at : {}", template_row_index);

    match umya_spreadsheet::writer::xlsx::write(&book, output_path) {
        Ok(_) => println!("Success writing to file: {}", output_path),
        Err(e) => println!("Error: {:?}", e),
    };

Output screenshot for explanation

Screenshot 2024-02-28 at 1 37 12 PM
MathNya commented 4 months ago

@BharathIO I'm sorry. It seems there was still a glitch. Ver 1.2.2 has been released. Please check it.

BharathIO commented 4 months ago

Thanks. It got fixed now, but LOV List use case still not working... could you please check https://github.com/MathNya/umya-spreadsheet/issues/178

BharathIO commented 4 months ago

Closing this as resolved.