calamine icon indicating copy to clipboard operation
calamine copied to clipboard

Time is recognized as Float.

Open HiraokaTakuya opened this issue 5 years ago • 6 comments

time.xlsx

time.xlsx is composed of one cell "00:15:00". This cell recognized as Float(0.0104166666666667). I expect as String("00:15:00"). Is this the intended behavior? The test code is below.

#[test]
fn time() {
    setup();

    let path = format!("{}/tests/time.xlsx", env!("CARGO_MANIFEST_DIR"));
    let mut excel: Xlsx<_> = open_workbook(&path).unwrap();

    let range = excel.worksheet_range("Sheet1").unwrap().unwrap();
    range_eq!(range, [[String("00:15:00".to_string())]]);
}

HiraokaTakuya avatar Sep 09 '19 04:09 HiraokaTakuya

Yes, internal representations of date and times are float in excel (just type this float value in a cell and force a time format on it). Unfortunately calamine doesn't yest recognize that the number is actually a time and give a corresponding interpreted result.

tafia avatar Sep 09 '19 07:09 tafia

Oh, internal representations of times are float! Thank you very much. I understood this behavior. Do you have any plans to deal with cell formats in the future?

HiraokaTakuya avatar Sep 09 '19 20:09 HiraokaTakuya

I'd love to do it but I don't have lot of time to do it properly. I'd accept any PR though 😄

tafia avatar Sep 10 '19 06:09 tafia

If I can improve it, I'll send PR.

HiraokaTakuya avatar Sep 10 '19 10:09 HiraokaTakuya

Just fyi, I've added a simple dates feature to try converting a DataType into a NaiveDate(Time). There is no automatic detection as it is more complicated but hopefully it'll be convenient already.

tafia avatar Oct 11 '19 07:10 tafia

Thank you very much! This is very helpful. And I'm sorry I couldn't contribute to it.

HiraokaTakuya avatar Oct 11 '19 10:10 HiraokaTakuya