The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Excel date formatting

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
couturier Posted - 08/13/2020 : 11:20:46 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2020b
Operating System:win10 64

Hi,

I'm importing an excel file with wks.ImportExcel().
It is quite fast and I can choose which sheet to import with og_get_excel_sheet_names()

However, I'm facing an issue with dates in cells
For example, 07/08/1988 (formatted as dd/mm/yyyy) is imported as 32362, which is not a julian value

If I import manually, it is shown correctly (but displays formatted as date, even if column format is numeric which is strange. I remember posting something about this but couldnt find)

How can I get the correct value ?

Thanx
4   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 08/18/2020 : 09:27:10 AM
Thank you for bringing this up. the sample code of the following page has been updated:
https://www.originlab.com/doc/OriginC/ref/Datasheet-ImportExcel

James
couturier Posted - 08/17/2020 : 02:36:19 AM
quote:
What a mess !!

To make things clear: this comment applies to Excel, not Origin

Anyway, thanks for the code example. I couldn't find any documentation about ExcelImportOptions, so I had just used RXC_VALUE.
The function works perfect
cpyang Posted - 08/15/2020 : 5:01:39 PM
I tested the following code in 2020b with a file I made with a column with date, and first tow as long name, and it imported correctly by setting column as date

#include <oExtFile.h>
void impxls(string strFile, bool bHeading = true, int nSheet = 0, bool bCellStyles = false)
{
	vector<string> vsSheets;
	int nn = get_excel_sheet_names(strFile, &vsSheets);
	if(nn <= 0) {
		out_str("not a valid Excel file");
		return;
	}
	Worksheet wks = Project.ActiveLayer();

	ExcelImportOptions stR;
	stR.xlsctrl.m_dwRXC = RXC_RESET_FORMAT | RXC_VALUE | RXC_VALUE_FORMAT | RXC_AUTO_RENAME_SHEET;
	if(bCellStyles)
		stR.xlsctrl.m_dwRXC |= RXC_STYLE;

	if(bHeading) {
		stR.header.SubHeaderLines = -1;
		stR.header.LongName = 1;
	}
	int nC2=-1;//to receive output actual last column
	
	//destination columns
	stR.xlsctrl.m_nStartColIndex = 0;
	stR.xlsctrl.m_pnLastColIndex = &nC2;

	int nErr = wks.ImportExcel(strFile, nSheet, &stR, true);
	if(nErr != 0)
		out_int("failed: ", nErr);
}


LT to call it

dlgfile g:=*.xlsx;impxls fname$;


CP
couturier Posted - 08/13/2020 : 11:28:31 AM
OK, I could find the solution here: https://www.originlab.com/doc/Quick-Help/Date_Conversion_Origin_Excel

What a mess !!

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000