use rust_xlsxwriter::{ExcelDateTime, Format, Workbook, XlsxError};
fn main() -> Result<(), XlsxError> {
let mut workbook = Workbook::new();
let worksheet = workbook.add_worksheet();
let format1 = Format::new().set_num_format("h:mm");
let format2 = Format::new().set_num_format("hh:mm");
let format3 = Format::new().set_num_format("hh:mm:ss");
let format4 = Format::new().set_num_format("hh:mm:ss.000");
let format5 = Format::new().set_num_format("h:mm AM/PM");
worksheet.set_column_width(0, 30)?;
let time = ExcelDateTime::from_hms_milli(2, 59, 3, 456)?;
worksheet.write_time_with_format(0, 0, &time, &format1)?;
worksheet.write_time_with_format(1, 0, &time, &format2)?;
worksheet.write_time_with_format(2, 0, &time, &format3)?;
worksheet.write_time_with_format(3, 0, &time, &format4)?;
worksheet.write_time_with_format(4, 0, &time, &format5)?;
workbook.save("worksheet.xlsx")?;
Ok(())
}