jmcnamara / rust_xlsxwriter

A Rust library for creating Excel XLSX files.
https://crates.io/crates/rust_xlsxwriter
Apache License 2.0
316 stars 25 forks source link

Support for custom paths #17

Closed songlinshu closed 1 year ago

songlinshu commented 1 year ago

Feature Request

How do I set the save path? c:\aa\cell_formats.xlsx workbook.save("c:\aa\cell_formats.xlsx")?;

jmcnamara commented 1 year ago

This is a general issue when working with Windows paths. The problem here is that \a and \c are control character in Rust/ASCII so you can't use them in a string.

error: unknown character escape: `a`
 --> src\main.rs:8:23
  |
8 |     workbook.save("c:\aa\cell_formats.xlsx")?;
  |                       ^ unknown character escape
  |

You can either use forward slashes:

   workbook.save("c:/aa/cell_formats.xlsx")?;

Or escape the escapes:

    workbook.save("c:\\aa\\cell_formats.xlsx")?;
songlinshu commented 1 year ago

Thank !