Closed manfredlotz closed 1 year ago
I want to create a cell with a time value so that I have for example
You need to create a xlsxwriter::DateTime object and set the year/month/day parts to 0. Like this:
use xlsxwriter::{DateTime, Workbook};
fn main() -> Result<(), xlsxwriter::XlsxError> {
let workbook = Workbook::new("datetime.xlsx");
let mut worksheet = workbook.add_worksheet(None)?;
let time_format = workbook.add_format().set_num_format("hh:mm");
worksheet.write_datetime(
0,
0,
&DateTime::new(0, 0, 0, 17, 00, 0.0),
Some(&time_format),
)?;
workbook.close()
}
Output:
Thanks a lot. Working fine.
Only one small thing.
Instead of
let workbook = Workbook::new("datetime.xlsx");
it must be
let workbook = Workbook::new("datetime.xlsx")?;
I want to create a cell with a time value so that I have for example
Important: There should be no date here.
In Libreoffice in Format Cells I would see
Creating the format sems easy
But I have no idea how to add a cell with a value, say 14:45h.