Skip to content

Commit

Permalink
version 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-U434MT0\hiro committed Aug 23, 2024
1 parent 5e9a59f commit 409d5cb
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "umya-spreadsheet"
version = "2.0.1"
version = "2.0.2"
authors = ["MathNya <[email protected]>"]
repository = "https://github.com/MathNya/umya-spreadsheet"
keywords = ["excel", "spreadsheet", "xlsx", "reader", "writer"]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
Please mention in issues if you have any questions.

## Update details
### ver 2.0.1
### ver 2.0.2
* Minor bug fixes

## Usage
### Installation
Add the following code to Cargo.toml
```toml
[dependencies]
umya-spreadsheet = "2.0.1"
umya-spreadsheet = "2.0.2"

# WebAssembly support
umya-spreadsheet = { version = "2.0.1", features = ["js"] }
umya-spreadsheet = { version = "2.0.2", features = ["js"] }
```

Add the following code to main.rs
Expand Down
2 changes: 1 addition & 1 deletion src/structs/defined_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl DefinedName {
attributes.push(("hidden", &hidden_str));
}
write_start_tag(writer, "definedName", attributes, false);
write_text_node_no_escape(writer, self.get_address());
write_text_node_conversion(writer, self.get_address());
write_end_tag(writer, "definedName");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl Style {
|| self.protection.is_some())
}

pub(crate) fn get_default_value() -> Self {
pub fn get_default_value() -> Self {
let mut def = Self::default();
def.set_font(Font::get_default_value());
def.set_borders(Borders::get_default_value());
Expand Down
12 changes: 12 additions & 0 deletions src/writer/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ where
writer.get_mut().write(data.into().as_bytes());
}

pub(crate) fn write_text_node_conversion<'a, S>(writer: &mut Writer<Cursor<Vec<u8>>>, data: S)
where
S: Into<Cow<'a, str>>,
{
let mut data: String = data.into().to_string();
data = data.replace("&", "&amp;");

This comment has been minimized.

Copy link
@agentjill

agentjill Aug 23, 2024

Contributor

Isn't these conversions already present in quick-xml unesacpe function

This comment has been minimized.

Copy link
@MathNya

MathNya Aug 26, 2024

Owner

As you pointed out, there was a function needed in quick-xml.
We will fix it to use this function in the next update.

data = data.replace("<", "&lt;");
data = data.replace(">", "&gt;");

write_text_node_no_escape(writer, data);
}

pub(crate) fn write_new_line(writer: &mut Writer<Cursor<Vec<u8>>>) {
write_text_node(writer, "\r\n");
}
Expand Down
50 changes: 35 additions & 15 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ extern crate chrono;
extern crate umya_spreadsheet;
use std::time::Instant;

use umya_spreadsheet::{EnumTrait, NumberingFormat, Style};
use helper::color;
use umya_spreadsheet::*;

#[test]
fn read_and_wite() {
Expand Down Expand Up @@ -1528,7 +1529,7 @@ fn issue_184() {
.unwrap()
.get_color()
.get_argb_with_theme(theme);
assert_eq!(color, "A78470");
assert_eq!(color, "A88570");
}

#[test]
Expand Down Expand Up @@ -1684,27 +1685,46 @@ fn issue_217() {

#[test]
fn issue_218() {
let mut out_book = umya_spreadsheet::new_file();
let mut out_book = new_file();
let out_sheet = out_book.new_sheet("listDataTable").unwrap();

let mut new_cond = umya_spreadsheet::ConditionalFormatting::default();
let mut ran = umya_spreadsheet::Range::default();
ran.set_range("B2:B4");
let mut color = Color::default();
color.set_argb("FF0000");
let mut pattern_fill = PatternFill::default();
pattern_fill.set_background_color(color);
let mut fill = Fill::default();
fill.set_pattern_fill(pattern_fill);
let mut style = Style::default();
style.set_fill(fill);

let mut form = Formula::default();
form.set_string_value("20");

let mut add = umya_spreadsheet::Address::default();
add.set_range(ran);
add.set_sheet_name("listDataTable");
let mut cond = ConditionalFormattingRule::default();
cond.set_type(ConditionalFormatValues::CellIs)
.set_operator(ConditionalFormattingOperatorValues::GreaterThan)
.set_priority(1)
.set_style(style)
.set_formula(form);

let mut form = umya_spreadsheet::Formula::default();
form.set_address(add);
form.set_string_value(">0");
let mut seq = SequenceOfReferences::default();
seq.set_sqref("B2:B4");

let mut cond = umya_spreadsheet::ConditionalFormattingRule::default();
cond.set_formula(form);
let mut new_cond = ConditionalFormatting::default();
new_cond.set_sequence_of_references(seq);

new_cond.set_conditional_collection(vec![cond]);
out_sheet.set_conditional_formatting_collection(vec![new_cond]);

let path = std::path::Path::new("./tests/result_files/issue_218.xlsx");
let _ = umya_spreadsheet::writer::xlsx::write(&out_book, path);
let _ = writer::xlsx::write(&out_book, path);
}

#[test]
fn issue_219() {
let path = std::path::Path::new("./tests/test_files/issue_219.xlsx");
let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();

let path = std::path::Path::new("./tests/result_files/issue_219.xlsx");
let _ = umya_spreadsheet::writer::xlsx::write(&book, path);
}
Binary file added tests/test_files/issue_219.xlsx
Binary file not shown.

0 comments on commit 409d5cb

Please sign in to comment.