Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function writeExcel(header: string[], rows: (string | number)[][]): Buffer {
headerStyle
.setAlign(FormatAlign.Top)
.setTextWrap()
.setBackgroundColor(Color.red());
.setBackgroundColor("Red");

// Write sheet header
worksheet.writeRowWithFormat(0, 0, header, headerStyle);
Expand Down
3 changes: 1 addition & 2 deletions examples/nodejs/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Color,
DocProperties,
Format,
FormatAlign,
Expand Down Expand Up @@ -31,7 +30,7 @@ function writeExcel(header: string[], rows: (string | number)[][]): Buffer {
headerStyle
.setAlign(FormatAlign.Top)
.setTextWrap()
.setBackgroundColor(Color.red());
.setBackgroundColor("Red");

// Write sheet header
worksheet.writeRowWithFormat(0, 0, header, headerStyle);
Expand Down
104 changes: 100 additions & 4 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ chrono = "0.4.42"
console_error_panic_hook = "0.1.7"
js-sys = "0.3.80"
rust_xlsxwriter = { version = "0.90.1", features = ["wasm", "chrono"] }
serde = { version = "1.0.219", features = ["derive"] }
tsify = "0.5.5"
wasm-bindgen = "0.2.94"
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::new_without_default)]

mod error;
mod macros;
mod wrapper;
12 changes: 12 additions & 0 deletions rust/src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#[macro_export]
macro_rules! impl_method {
($self:ident.$method:ident($($arg:expr),*)) => {
let mut lock = $self.lock();
let mut inner = std::mem::take(&mut *lock);
inner = inner.$method($($arg),*);
let _ = std::mem::replace(&mut *lock, inner);
return Self {
inner: Arc::clone(&$self.inner),
}
};
}
4 changes: 2 additions & 2 deletions rust/src/wrapper/chart/chart_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl ChartFont {
/// @param {Color} color - The font color property.
/// @return {ChartFont} - The ChartFont instance.
#[wasm_bindgen(js_name = "setColor")]
pub fn set_color(&mut self, color: &Color) -> ChartFont {
self.inner.set_color(color.inner);
pub fn set_color(&mut self, color: Color) -> ChartFont {
self.inner.set_color(color);
self.clone()
}

Expand Down
4 changes: 2 additions & 2 deletions rust/src/wrapper/chart/chart_gradient_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub struct ChartGradientStop {
#[wasm_bindgen]
impl ChartGradientStop {
#[wasm_bindgen(constructor)]
pub fn new(color: &Color, position: u8) -> ChartGradientStop {
pub fn new(color: Color, position: u8) -> ChartGradientStop {
ChartGradientStop {
inner: xlsx::ChartGradientStop::new(color.inner, position),
inner: xlsx::ChartGradientStop::new(color, position),
}
}
}
4 changes: 2 additions & 2 deletions rust/src/wrapper/chart/chart_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ impl ChartLine {
}

#[wasm_bindgen(js_name = "setColor")]
pub fn set_color(&mut self, color: &Color) -> ChartLine {
self.inner.set_color(color.inner);
pub fn set_color(&mut self, color: Color) -> ChartLine {
self.inner.set_color(color);
self.clone()
}

Expand Down
8 changes: 4 additions & 4 deletions rust/src/wrapper/chart/chart_pattern_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ impl ChartPatternFill {
}

#[wasm_bindgen(js_name = "setBackgroundColor")]
pub fn set_background_color(&mut self, color: &Color) -> ChartPatternFill {
self.inner.set_background_color(color.inner);
pub fn set_background_color(&mut self, color: Color) -> ChartPatternFill {
self.inner.set_background_color(color);
self.clone()
}

#[wasm_bindgen(js_name = "setForegroundColor")]
pub fn set_foreground_color(&mut self, color: &Color) -> ChartPatternFill {
self.inner.set_foreground_color(color.inner);
pub fn set_foreground_color(&mut self, color: Color) -> ChartPatternFill {
self.inner.set_foreground_color(color);
self.clone()
}
}
4 changes: 2 additions & 2 deletions rust/src/wrapper/chart/chart_solid_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ impl ChartSolidFill {
/// @param {Color} color - The color property.
/// @return {ChartSolidFill} - The ChartSolidFill instance.
#[wasm_bindgen(js_name = "setColor")]
pub fn set_color(&mut self, color: &Color) -> ChartSolidFill {
self.inner.set_color(color.inner);
pub fn set_color(&mut self, color: Color) -> ChartSolidFill {
self.inner.set_color(color);
self.clone()
}

Expand Down
Loading