@@ -3,9 +3,9 @@ use std::sync::{Arc, Mutex, MutexGuard};
3
3
use rust_xlsxwriter as xlsx;
4
4
use wasm_bindgen:: prelude:: * ;
5
5
6
- use crate :: { error :: XlsxError , wrapper :: utils , DeepClone } ;
6
+ use crate :: { DeepClone } ;
7
7
8
- use super :: { color:: Color , WasmResult } ;
8
+ use super :: { color:: Color } ;
9
9
10
10
/// The `Format` struct is used to define cell formatting for data in a
11
11
/// worksheet.
@@ -189,21 +189,10 @@ impl Format {
189
189
/// Create a new Format object.
190
190
///
191
191
/// Create a new Format object to use with worksheet formatting.
192
- /// If a Format obejct is provided as an argument, it will be cloned.
193
192
#[ wasm_bindgen( constructor) ]
194
- pub fn new ( format : Option < JsFormat > ) -> WasmResult < Format > {
195
- if let Some ( format) = format {
196
- // HACK: Since wasm-bindgen does not supports Option<&RustStruct>, we cast JsValue as Format.
197
- let format = utils:: format_of_jsval ( & format) . ok_or ( XlsxError :: Type (
198
- "Expected a value of type Format" . to_string ( ) ,
199
- ) ) ?;
200
- // Clone the inner object
201
- let format = format. deep_clone ( ) ;
202
- Ok ( format)
203
- } else {
204
- Ok ( Format {
205
- inner : Arc :: new ( Mutex :: new ( xlsx:: Format :: new ( ) ) ) ,
206
- } )
193
+ pub fn new ( ) -> Format {
194
+ Format {
195
+ inner : Arc :: new ( Mutex :: new ( xlsx:: Format :: new ( ) ) ) ,
207
196
}
208
197
}
209
198
@@ -815,6 +804,11 @@ impl Format {
815
804
inner : Arc :: clone ( & self . inner ) ,
816
805
}
817
806
}
807
+
808
+ #[ wasm_bindgen( js_name = "clone" ) ]
809
+ pub fn clone_format ( & self ) -> Format {
810
+ self . deep_clone ( )
811
+ }
818
812
}
819
813
820
814
impl DeepClone for Format {
0 commit comments