NumberFormat e date

F

Francesco Geri

Salve, ho una colonna in cui metto delle date via codice, vorrei formattarla
e per questo uso:

CType(workSheet.Columns(3), Excel.Range).NumberFormat = "dd/mm/yyyy"

(codice VB.NET)

Quel codice genera la seguante eccezione:
---------------------
Impossibile utilizzare il formato numerico digitato.
Utilizzare uno dei formati numerici incorporati. [ ... ]
-------------------------

funziona bene se uso "gg/mm/aaaa" invece di "dd/mm/yyyy".

Non mi sembra il caso di usare "gg/mm/aaaa", visto che il codice dovrebbe
funzionare sempre, anche se ho sistema operativo ed Excel in inglese....

Come potre fare?
Ciao e grazie a tutti

Franx
 
F

Francesco Geri

Ops, I'm sorry, I posted in italian....

This is the translation:

I want to format an excel worksheet column to contains some dates. My code
VB.NET is:

CType(workSheet.Columns(3), Excel.Range).NumberFormat = "dd/mm/yyyy"

but that code raise an exception (the numerical format is incorrect... etc
etc)

The code correct is:
CType(workSheet.Columns(3), Excel.Range).NumberFormat = "gg/mm/aaaa"

because my operating system (or my excel?) is installed in italian.

But, I want a code that work well anywhere... How can I obtain that?

Thanks!

Franx
 
T

Tom Ogilvy

You might check out the free chapter posted on line at Stephen Bullen's
site. This is a comprehensive reference on international issues when
programming Excel:

http://www.oaltd.co.uk/ExcelProgRef/ch22/

--
Regards,
Tom Ogilvy


Francesco Geri said:
Ops, I'm sorry, I posted in italian....

This is the translation:

I want to format an excel worksheet column to contains some dates. My code
VB.NET is:

CType(workSheet.Columns(3), Excel.Range).NumberFormat = "dd/mm/yyyy"

but that code raise an exception (the numerical format is incorrect... etc
etc)

The code correct is:
CType(workSheet.Columns(3), Excel.Range).NumberFormat = "gg/mm/aaaa"

because my operating system (or my excel?) is installed in italian.

But, I want a code that work well anywhere... How can I obtain that?

Thanks!

Franx




Francesco Geri said:
Salve, ho una colonna in cui metto delle date via codice, vorrei
formattarla e per questo uso:

CType(workSheet.Columns(3), Excel.Range).NumberFormat = "dd/mm/yyyy"

(codice VB.NET)

Quel codice genera la seguante eccezione:
---------------------
Impossibile utilizzare il formato numerico digitato.
Utilizzare uno dei formati numerici incorporati. [ ... ]
-------------------------

funziona bene se uso "gg/mm/aaaa" invece di "dd/mm/yyyy".

Non mi sembra il caso di usare "gg/mm/aaaa", visto che il codice dovrebbe
funzionare sempre, anche se ho sistema operativo ed Excel in inglese....

Come potre fare?
Ciao e grazie a tutti

Franx
 
F

Francesco Geri

Thanks for the link
franx

Tom Ogilvy said:
You might check out the free chapter posted on line at Stephen Bullen's
site. This is a comprehensive reference on international issues when
programming Excel:

http://www.oaltd.co.uk/ExcelProgRef/ch22/

--
Regards,
Tom Ogilvy


Francesco Geri said:
Ops, I'm sorry, I posted in italian....

This is the translation:

I want to format an excel worksheet column to contains some dates. My
code
VB.NET is:

CType(workSheet.Columns(3), Excel.Range).NumberFormat = "dd/mm/yyyy"

but that code raise an exception (the numerical format is incorrect...
etc
etc)

The code correct is:
CType(workSheet.Columns(3), Excel.Range).NumberFormat = "gg/mm/aaaa"

because my operating system (or my excel?) is installed in italian.

But, I want a code that work well anywhere... How can I obtain that?

Thanks!

Franx




Francesco Geri said:
Salve, ho una colonna in cui metto delle date via codice, vorrei
formattarla e per questo uso:

CType(workSheet.Columns(3), Excel.Range).NumberFormat = "dd/mm/yyyy"

(codice VB.NET)

Quel codice genera la seguante eccezione:
---------------------
Impossibile utilizzare il formato numerico digitato.
Utilizzare uno dei formati numerici incorporati. [ ... ]
-------------------------

funziona bene se uso "gg/mm/aaaa" invece di "dd/mm/yyyy".

Non mi sembra il caso di usare "gg/mm/aaaa", visto che il codice dovrebbe
funzionare sempre, anche se ho sistema operativo ed Excel in
inglese....

Come potre fare?
Ciao e grazie a tutti

Franx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Date sql2000 e sqlce 1

Top