Skip to content

Commit 908b716

Browse files
committed
[dev] add style and size attributes for borders
1 parent edf12f8 commit 908b716

File tree

4 files changed

+239
-147
lines changed

4 files changed

+239
-147
lines changed

example/datasets.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -177,70 +177,70 @@ var example = {
177177
"fontFamily": "Calibri",
178178
"fontSize": "16px",
179179
"color": "rgba(0,0,0,1)",
180-
"borderRight": "1px solid #000",
181-
"borderLeft": "1px solid #000",
180+
"borderRight": "2px solid #34e343",
181+
"borderLeft": "2px solid #34e343",
182182
"format": "General",
183-
"borderTop": "1px solid #000",
184-
"borderBottom": "1px solid #000"
183+
"borderTop": "2px solid #34e343",
184+
"borderBottom": "2px solid #34e343"
185185
},
186186
{
187187
"fontSize": "16px",
188188
"fontFamily": "Calibri",
189-
"borderLeft": "1px solid #000",
190-
"borderTop": "1px solid #000",
191-
"borderRight": "1px solid #000",
189+
"borderLeft": "0.5px solid #000",
190+
"borderTop": "0.5px solid #000",
191+
"borderRight": "0.5px solid #000",
192192
"format": "General",
193-
"borderBottom": "1px solid #000"
193+
"borderBottom": "0.5px solid #000"
194194
},
195195
{
196196
"fontWeight": "bold",
197-
"borderBottom": "1px solid #000",
197+
"borderBottom": "1px dashed #701243",
198198
"verticalAlign": "top",
199199
"background": "rgba(234,234,234,1)",
200200
"fontSize": "15px",
201201
"fontFamily": "PT Sans",
202-
"borderTop": "1px solid #000",
202+
"borderTop": "1px dashed #701243",
203203
"format": "General",
204204
"color": "rgba(129,129,129,1)",
205-
"borderLeft": "1px solid #000",
206-
"borderRight": "1px solid #000",
205+
"borderLeft": "1px dashed #701243",
206+
"borderRight": "1px dashed #701243",
207207
"textAlign": "center"
208208
},
209209
{
210210
"color": "rgba(129,129,129,1)",
211-
"borderBottom": "1px solid #000",
211+
"borderBottom": "1px dotted #000",
212212
"fontSize": "15px",
213213
"fontFamily": "PT Sans",
214214
"verticalAlign": "center",
215215
"format": "General",
216216
"textAlign": "center",
217-
"borderTop": "1px solid #000",
217+
"borderTop": "1px dotted #000",
218218
"fontWeight": "bold",
219-
"borderRight": "1px solid #000",
220-
"borderLeft": "1px solid #000"
219+
"borderRight": "1px dotted #000",
220+
"borderLeft": "1px dotted #000"
221221
},
222222
{
223223
"fontFamily": "PT Sans",
224-
"borderBottom": "1px solid #000",
225-
"borderTop": "1px solid #000",
224+
"borderBottom": "1px double #000",
225+
"borderTop": "1px double #000",
226226
"fontSize": "15px",
227227
"verticalAlign": "center",
228228
"color": "rgba(129,129,129,1)",
229229
"fontWeight": "bold",
230230
"textAlign": "right",
231231
"format": "General",
232-
"borderLeft": "1px solid #000",
233-
"borderRight": "1px solid #000"
232+
"borderLeft": "1px double #000",
233+
"borderRight": "1px double #000"
234234
},
235235
{
236236
"format": "General",
237-
"borderBottom": "1px solid #000",
237+
"borderBottom": "1px solid #94ff4d",
238238
"background": "rgba(234,234,234,1)",
239239
"verticalAlign": "top",
240240
"textAlign": "center",
241-
"borderTop": "1px solid #000",
242-
"borderLeft": "1px solid #000",
243-
"borderRight": "1px solid #000",
241+
"borderTop": "1px solid #94ff4d",
242+
"borderLeft": "1px solid #94ff4d",
243+
"borderRight": "1px solid #94ff4d",
244244
"color": "rgba(129,129,129,1)",
245245
"fontSize": "15px",
246246
"fontFamily": "PT Sans"

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
let $ = document.querySelector.bind(document);
2424

2525
const dataArea = $(".spreadsheet-data");
26-
dataArea.value = JSON.stringify(example2, undefined, 2);
26+
dataArea.value = JSON.stringify(example, undefined, 2);
2727

2828
$("#convert-button").addEventListener("click", function(e){
2929
import("./js/module").then(({ convert }) => {

src/lib.rs

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn get_styles_data(style_table: StyleTable) -> String {
254254
match font.size {
255255
Some(ref size) => {
256256
let mut sz = Element::new("sz");
257-
sz.add_attr("val", size);
257+
sz.add_attr("val", size.to_string());
258258
font_children.push(sz);
259259
},
260260
None => ()
@@ -296,48 +296,17 @@ fn get_styles_data(style_table: StyleTable) -> String {
296296
let mut border_element = Element::new("border");
297297
let mut children: Vec<Element> = vec![];
298298

299-
if let Some(top) = &border.top {
300-
let mut el = Element::new("top");
301-
el.add_attr("style", "thin");
302-
303-
if let Some(color) = &top.color {
304-
let mut color_element = Element::new("color");
305-
color_element.add_attr("rgb", color);
306-
children.push(el);
307-
}
299+
if let Some(b) = &border.top {
300+
children.push(b.to_xml_el())
308301
}
309-
310-
if let Some(right) = &border.right {
311-
let mut el = Element::new("right");
312-
el.add_attr("style", "thin");
313-
314-
if let Some(color) = &right.color {
315-
let mut color_element = Element::new("color");
316-
color_element.add_attr("rgb", color);
317-
children.push(el);
318-
}
302+
if let Some(b) = &border.right {
303+
children.push(b.to_xml_el())
319304
}
320-
321-
if let Some(bottom) = &border.bottom {
322-
let mut el = Element::new("bottom");
323-
el.add_attr("style", "thin");
324-
325-
if let Some(color) = &bottom.color {
326-
let mut color_element = Element::new("color");
327-
color_element.add_attr("rgb", color);
328-
children.push(el);
329-
}
305+
if let Some(b) = &border.bottom {
306+
children.push(b.to_xml_el())
330307
}
331-
332-
if let Some(left) = &border.left {
333-
let mut el = Element::new("left");
334-
el.add_attr("style", "thin");
335-
336-
if let Some(color) = &left.color {
337-
let mut color_element = Element::new("color");
338-
color_element.add_attr("rgb", color);
339-
children.push(el);
340-
}
308+
if let Some(b) = &border.left {
309+
children.push(b.to_xml_el())
341310
}
342311

343312
border_element.add_children(children);

0 commit comments

Comments
 (0)