I've got a small app which reads dates from an Excel spreadsheet adding
them onto a listview. The problem is that the dates are read in as ints
(or possibly doubles, they look like ints). So for instance the date
03.07.2000 is represented like 36710, 04.07.2000 as 36711 etc. The
problem as you may understand is that I want them to be stored as dates
(or ideally as strings). I've tried all sorts of Convert.* functions
and casts but they all end up throwing exceptions.
The column is read like this:
Excel.Range range = worksheet.get_R ange("A"+i.ToSt ring(),
"A"+i.ToString( )); and currently the list view is populated like this:
listView1.Items .Add(new ListViewItem(ra nge.Cells.Value 2.ToString()));
Does anyone have any hints, tips, code snippets or otherwise which can
help me solve my problem?
MTIA,
Håvard 1 7416
Dates in Excel are based on 1/1/1900, so the # you are getting is the # of
days since then, thus, if you do something like:
TimeSpan dateFromExcel = new TimeSpan(38530, 0,0,0);
DateTime resultingDate = new DateTime(1900,1 ,1).Add(dateFro mExcel);
Console.WriteLi ne( resultingDate.T oString() );
In theory you should get the correct result... however I am getting a date
of 7/5/2000 (MM/DD/YYYY), constantly 2 days off.
I apologize for not being able to solve this for you completely, but this
will get you pretty close. I hope this helps.
Brendan
"HÃ¥vard Olerud Eriksen" wrote: I've got a small app which reads dates from an Excel spreadsheet adding them onto a listview. The problem is that the dates are read in as ints (or possibly doubles, they look like ints). So for instance the date 03.07.2000 is represented like 36710, 04.07.2000 as 36711 etc. The problem as you may understand is that I want them to be stored as dates (or ideally as strings). I've tried all sorts of Convert.* functions and casts but they all end up throwing exceptions. The column is read like this: Excel.Range range = worksheet.get_R ange("A"+i.ToSt ring(), "A"+i.ToString( )); and currently the list view is populated like this: listView1.Items .Add(new ListViewItem(ra nge.Cells.Value 2.ToString()));
Does anyone have any hints, tips, code snippets or otherwise which can help me solve my problem?
MTIA, HÃ¥vard
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hans [DiaGraphIT] |
last post by:
Hi!
I want to export a dataset to an excel file. I found following code on the
net...
( http://www.codeproject.com/csharp/Export.asp )
Excel.ApplicationClass excel = new ApplicationClass();
excel.Application.Workbooks.Add(true);
DataTable table = DATASETNAME.Tables;
|
by: |
last post by:
Hello,
I have a routine in my Windows application that exports the contents of a
datagrid to Excel. It is modeled closely after the HowTo example on MSDN:
http://tinyurl.com/5g2jm.
Depending on the number of rows/columns in the datagrid, it can be extremely
slow (several minutes to populate a 1000x50 spreadsheet). That is
understandable, looking at the number of steps to copy over just one row.
|
by: |
last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It
works perfectly on my machine, but it fails on my customers' PCs that have
identical versions of Win XP (SP1) and Excel (SP1) installed.
The error is:
System.Runtime.InteropServices.COMException(0x800A03EC): Exception from
HRESULT: 0x800A03EC.
at Microsoft.Office.Interop.Excel._Worksheet.Paste(Object Destination,
Object Link)
at...
|
by: John Machin |
last post by:
I am pleased to announce a new general release (0.5.2) of xlrd, a Python
package for extracting data from Microsoft Excel spreadsheets.
CHANGES:
* Book and sheet objects can now be pickled and unpickled. Instead of
reading a large spreadsheet multiple times, consider pickling it once
and loading the saved pickle; can be much faster.
* Now works with Python 2.1. Backporting to Python 2.1 was partially
|
by: jereviscious |
last post by:
Hi all - Last resort time.
I'm importing data from a spreadsheet that I receive from one of my vendor
using interop.excel.
The date field in excel is entered as 4/7/2006, but when I retrieve the
value, it returns a double 38449.0.
I can't figure out how to convert this value into a proper date. I have no
Idea what excel is doing with this date. Also, when I enter in 38449 into
| |
by: kath |
last post by:
How do I read an Excel file in Python?
I have found a package to read excel file, which can be used on any
platform.
http://www.lexicon.net/sjmachin/xlrd.htm
I installed and working on the examples, I found its printing of cell's
contents in a different manner.
print sh.row(rx)
|
by: sherifffruitfly |
last post by:
Hi,
I'm using an adaptation of excel-reading code that's all over the
internet - I don't much like or understand it, but it has worked for me
in the past.... beggars can't be choosers... :
Excel.Application excelObj = new Excel.Application();
Excel.Workbook theWorkbook = excelObj.Workbooks.Open(path+filename,
0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false,
|
by: Bharathi |
last post by:
Hi,
I got strucked with reading date value from excel file using
C#.NET.
For Jan-2000 the value I am getting is 36526.0.
For all other dates also I am getting some double value like this.
Is there any manipulation so that I can find out the date entered in
|
by: Dirk Hagemann |
last post by:
Hello,
From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put
3566839 in field A1 and switch the format of the result-field to the
corresponding...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |