Comments (19)
I found out about a workaround until this is officially fixed. Please take a look at this article that explains that number means. You can write a simple function to convert this number into a DateTime.
How Dates Work in Excel – The Calendar System Explained + Video
Each Day is a Whole Number
Each day is represented by one whole number in Excel. Type a 1 in any cell and then format it as a date. You will get 1/1/1900. The first day of the calendar system.Type a 2 in a cell and format it as a date. You will get 1/2/1900, or January 2nd. This means that one whole day is
represented by one whole number is Excel.
You can also take a cell that contains a date and format it as a number.For example, this post was published on 1/27/2016. Put that number in a cell (the keyboard shortcut to enter today's date is Ctrl+;), and then format it as a number or General.
You will see the number 42,396. This is the number of days that have elapsed since 1/1/1900.
from excel.
Here's a simple static util method I use to convert excel dates to
DateTime
. Hope this helps :)import 'package:jiffy/jiffy.dart'; static DateTime tryParseExcelDateTimeDouble(double dateDouble, {DateTime ifInvalid}) { if (dateDouble == null || dateDouble < 1) return ifInvalid; return Jiffy(DateTime(1900, 1, 1)) .add(days: dateDouble.toInt() - 1) .dateTime; }
It'll work if you change dateDouble.toInt() - 1
to dateDouble.toInt() - 2
from excel.
Also, the date value that we receive is not consistent. The CellType
s are either string or integer and it is pretty random as you can see here. It makes it very difficult to identify if a cell is an integer or date in disguise. For a sheet with a predetermined date column, it would be easy to convert them to DateTime
depending on its type (string or int) but not for a generalized sheet. It would be great if you could also introduce a new CellType.date
and return an actual DateTime
object instead of a string/int.
from excel.
Of course, it must be a stress for you to dedicate to things outside of work and we are really grateful for it. All I can hope for is you to push fixes whenever possible.
from excel.
Here's a simple static util method I use to convert excel dates to DateTime
. Hope this helps :)
import 'package:jiffy/jiffy.dart';
static DateTime tryParseExcelDateTimeDouble(double dateDouble, {DateTime ifInvalid}) {
if (dateDouble == null || dateDouble < 1) return ifInvalid;
return Jiffy(DateTime(1900, 1, 1))
.add(days: dateDouble.toInt() - 1)
.dateTime;
}
from excel.
Started working on this in beta (unstable) branch :: https://github.com/kawal7415/excel/tree/beta
As we had started to work on providing Formula functionality, So we will be providing various CellType support.
Thank You
Stay Tuned...
Long Live Open S🔥urce
from excel.
Is there a solution for this problem.
I still am not able to recieve fields as date.
Excel only recieves the fields as date if it is in the first column. For columns other than that, I get values such as 43959.
from excel.
Hello, how do I receive the fields as Date?
I have a column with the fields as Date but when I order to display some numbers appear.
For example the date in the file is: 08/05/2020 12:00:00
No Flutter in print (as your example) appears: 43959.5
How to solve?
Hello, did you manage to solve this issue?
from excel.
I am having the same issue indicated above
from excel.
Same issue.
from excel.
Or you could simply return the default string value as it appears on the Excel (dd-mm-yyyy) and let us parse it. That would be really simple and easy.
from excel.
@ashishbeck
Structure of excel doesn't support to have normal date as String, If I would have done that way then the excel file would have easily broken on Google Sheets,, Sheets from the Apple software and also on Microsoft Excel.
I thinks that the answer from @nipunasudha would be promising to help you out in this scenario until I push a fix for it.
from excel.
Awaiting for DateTime column )
from excel.
@nipunasudha your solution worked for me THANKS with just small issue its showing me one day ahead. Is that a big problem or should i manually add 1 day to it.
from excel.
Is there a way to set a cell as a Date when exporting Excel?
from excel.
@BugsBuggy and how can we store date values?
from excel.
Any news?
from excel.
I implemented the support for date, time and date-time values, here is the PR: #279
And so you may also use it like this as long as it is not available in the main branch:
# pubspec.yaml
dependencies:
excel
git: https://github.com/quaaantumdev/excel.git
( the repository may be deleted once the changes are merged )
from excel.
Can you try version:
excel: ^4.0.0
from excel.
Related Issues (20)
- Help: Determining the type of a cell HOT 1
- How to use custom Chinese fonts
- Excel - Roadmap Tasks HOT 2
- Default constructors for simplicity
- rename sheet breaks with archive 3.4.10 HOT 1
- Excel.decodeBytes -> Bad State too many elements
- The argument type 'String' can't be assigned to the parameter type 'ExcelColor' HOT 4
- How to parse Excel cell merging information?
- Bug reading SpannedItems as empty HOT 2
- README.md demo doesn't compile since 4.0.3 update
- Couldn't decode ".xls" file HOT 1
- Cannot delete sheets HOT 6
- DateTimeCellValue not working on Windows
- Very inefficient RAM usage HOT 2
- Can't read the XLSX file from http request - Damaged Excel file: Corrupted Excel file HOT 1
- How to save .csv
- Bad state: No element while parsing
- Can I select the sheet I want to open in a file that has multiple sheets?
- update package HOT 5
- Cells with a time below `02:25:00` are recognized as `DateTimeCellValue` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from excel.