Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number Formats ignore literal strings and characters #230

Open
Redfire75369 opened this issue Oct 4, 2024 · 2 comments
Open

Number Formats ignore literal strings and characters #230

Redfire75369 opened this issue Oct 4, 2024 · 2 comments

Comments

@Redfire75369
Copy link

If a number format like "0\ 0" is provided, the space in the middle is ignored.

Code:

let mut wb = new_file();
let sheet = wb.get_sheet_mut(&0).unwrap();
sheet.get_cell_mut("A1").set_value("12");
sheet.get_style_mut("A1")
        .get_number_format_mut()
        .set_format_code("#\\ #");
println!("{:#?}", sheet.get_formatted_value("A1"));

Expected Output: "1 2"
Actual Output: "12"

I believe the problematic code is here:

let re = Regex::new(r"\$[^0-9]*").unwrap();
if re.find(&format).ok().flatten().is_some() {
let mut item: Vec<String> = Vec::new();
for ite in re.captures(&format).ok().flatten().unwrap().iter() {
item.push(ite.unwrap().as_str().to_string());
}
value = format!("{}{}", item.get(0).unwrap(), value);
// // Currency or Accounting
// let currency_code = item.get(1).unwrap().to_string();
// value = Regex::new(r#"\[\$([^\]]*)\]"#).unwrap().replace_all(&value, currency_code.as_str()).to_string();
}

@MathNya
Copy link
Owner

MathNya commented Oct 7, 2024

@Redfire75369
Thank you for contacting us.
We will review the situation and correct it.

MathNya pushed a commit that referenced this issue Oct 11, 2024
@MathNya
Copy link
Owner

MathNya commented Oct 11, 2024

@Redfire75369
Sorry, the process here is quite complex and will take time to correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants