Duration formating in XlsIO

Hi,

I try to export an excel document with durations, but I can't figure out how I can set the duration format.

It works to set the DateTime from epoch and format it like this 'hh:mm:ss' with the number format, but that means it still carries the date.

Is there a better way to enable duration formatting via XlsIO?

Thank you,

Ben


6 Replies

RS Ramya Sivakumar Syncfusion Team April 28, 2022 11:16 AM UTC

Hi Ben,


Greetings from Syncfusion.


We suspect you are asking about how to set the time format for the Excel cells. Kindly use the following code snippet to set the time number format.


Code Snippet:

final Workbook workbook = Workbook(1);

final Worksheet sheet = workbook.worksheets[0];

 

final Range range3 = sheet.getRangeByName('A1');

range3.setDateTime(DateTime(2014, 10, 12, 20, 5, 5));

range3.numberFormat = 'h:mm:ss';

 

final List<int> bytes = workbook.saveAsStream();

saveAsExcel(bytes, 'Time.xlsx');

workbook.dispose();


Kindly refer to the following link to know more about the Number format

https://help.syncfusion.com/flutter/xlsio/working-with-number-format#time


If we misunderstood your query then kindly revert us the exact issue in a detailed manner.


Regards,

Ramya.



BE Ben April 28, 2022 02:01 PM UTC

Hi Ramya,


Thanks for your response.

What you have in your example is exactly what I tried.

The problem is that I get then a date time and not a duration:


Excel actually has a duration format that also makes it possible to calculate over durations:

Whit this format, I get an output that looks like this:


Thanks,

Ben



RS Ramya Sivakumar Syncfusion Team April 29, 2022 01:36 PM UTC

Hi Ben,


We are not able to set the duration format in the Excel file. Could you please share the Excel file with the duration format which would help us to proceed further.


We appreciate your patience.


Regards,

Ramya.



BE Ben April 29, 2022 03:53 PM UTC

Hi Ramya,

Yes please find attached a zip with an xlsx file with duration formating

(sorry, the file uploader didn't let me upload an xlsx file directly).

Regards,

Ben


Attachment: jobeventsexport_27_Apr_2022.xlsx_a0c98571.zip


RS Ramya Sivakumar Syncfusion Team May 2, 2022 12:52 PM UTC

Hi Ben,


Thank you for sharing the Excel document. We are checking the feasibility to set the duration formatting in XlsIO and share the details in 2 business days, May 5, 2022.


We appreciate your patience.


Regards,

Ramya.



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team May 5, 2022 03:48 PM UTC

Hi Ben,


We appreciate your patience.


Flutter XlsIO do not have direct support to set the time value alone. However, this requirement can be achieved with a simple workaround by setting the time value(hours, minutes, seconds) and applying the duration number format.


We have prepared a simple sample for this and it can be downloaded from below link.

Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/flutter_application-473825885.zip


Kindly try the sample and let us know if this helps.


Regards,

Keerthi.


Loader.
Up arrow icon