473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

c# - excel - interop - numberformat

stf
Hello,

I use c# to start excel and to get numberformat of active cell. VBA outputs
results as expected, but via c# i get result 'Standard' instead of 'General'
for a call to numberformat. Why?
It look's like 'numberformatlocal' is returned instead of 'numberformat'.

Output of C#:
Numberformat:Standard
NumberformatLocal:Standard

Output of VBA:
Numberformat:General
NumberformatLocal:Standard

System:
- Windows XP, SP1
- Excel 2002, SP2

Note: I'm from austria - language is german

wkr
Robert

---------------------------------------------
C#
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using Excel;
  3.  
  4. namespace ConsoleApplication1 {
  5. class Class1   {
  6. [STAThread]
  7. static void Main(string[] args) {
  8. Excel.Application app = new Excel.Application();
  9. app.Visible = true;
  10. try {
  11. app.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
  12. _Worksheet worksheet = (_Worksheet) app.ActiveSheet;
  13. if (worksheet == null) {
  14. Console.WriteLine ("ERROR: worksheet == null");
  15. }
  16. Console.WriteLine("Numberformat:"+app.ActiveCell.NumberFormat);
  17.  
  18. Console.WriteLine("NumberformatLocal:"+app.ActiveCell.NumberFormatLocal);
  19. } catch (Exception e) {
  20. Console.Out.WriteLine(e);
  21. }
  22. app.Quit();
  23. }
  24. }
  25. }
  26.  
---------------------------------------------
VBA
Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Debug.Print "Numberformat:" & ActiveCell.NumberFormat
  3. Debug.Print "NumberformatLocal:" & ActiveCell.NumberFormatLocal
  4. End Sub
  5.  
Nov 16 '05 #1
1 14352
That's probably a quirk with the language install. I think you should report
this to Microsoft Product Support.

--
Regards,
Alvin Bruney

Shameless Author plug
The Microsoft Office Web Components Black Book with .NET
http://tinyurl.com/27cok
"stf" <st*@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
Hello,

I use c# to start excel and to get numberformat of active cell. VBA
outputs
results as expected, but via c# i get result 'Standard' instead of
'General'
for a call to numberformat. Why?
It look's like 'numberformatlocal' is returned instead of 'numberformat'.

Output of C#:
Numberformat:Standard
NumberformatLocal:Standard

Output of VBA:
Numberformat:General
NumberformatLocal:Standard

System:
- Windows XP, SP1
- Excel 2002, SP2

Note: I'm from austria - language is german

wkr
Robert

---------------------------------------------
C#
Expand|Select|Wrap|Line Numbers
  1.  using System;
  2.  using Excel;
  3.  namespace ConsoleApplication1 {
  4.   class Class1   {
  5.       [STAThread]
  6.       static void Main(string[] args) {
  7.         Excel.Application app = new Excel.Application();
  8.         app.Visible = true;
  9.         try {
  10.            app.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
  11.            _Worksheet worksheet = (_Worksheet) app.ActiveSheet;
  12.            if (worksheet == null) {
  13.               Console.WriteLine ("ERROR: worksheet == null");
  14.            }
  15.            Console.WriteLine("Numberformat:"+app.ActiveCell.NumberFormat);
  16.  Console.WriteLine("NumberformatLocal:"+app.ActiveCell.NumberFormatLocal);
  17.          } catch (Exception e) {
  18.            Console.Out.WriteLine(e);
  19.          }
  20.          app.Quit();
  21.       }
  22.    }
  23.  }
  24.  

---------------------------------------------
VBA
Expand|Select|Wrap|Line Numbers
  1.  Sub test()
  2.     Debug.Print "Numberformat:" & ActiveCell.NumberFormat
  3.     Debug.Print "NumberformatLocal:" & ActiveCell.NumberFormatLocal
  4.  End Sub
  5.  

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: B | last post by:
Using Access2000, the sample code below is what I have been modifying and working on since the past week and I could not get it to work properly. What I wanted to accomplish: 1) read from a...
4
by: BerkshireGuy | last post by:
I have the following Access code that exports to Excel, inserts a title, changes the color of the title, and then changes the format of several columns to currency. The following code sometimes...
3
by: Snoozer654 | last post by:
I'm trying to format a cell in Excel using the Excel Interop. Example: I need to format a cell to be "610.00" Excel defaults this to 610. When I try to match on this value of course I am not able...
7
by: KC | last post by:
Does anybody know how to add a specific number of worksheets to an Excel spreadsheet through VB.net? I'm trying to export some datatables to an excel file, but I only want as many sheets in the...
4
by: goonsquad | last post by:
I'm writing an Excel Automation app and I'm running to a problem early on with what should be a basic step. Dim oExcel As Object Dim oBook As Object Dim oSheet As Object Dim oRng As...
3
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1...
8
by: John Brock | last post by:
I am creating an Excel workbook using VB.NET, and have run into a problem. Excel at times insists on reformatting data that I enter into cells, e.g., converting "01234" to "1234", and this screws...
6
by: yoavyoavyoav | last post by:
Hi There , I have an application that creates a csv file and I want it to display it in excel after creation. I've used to following code - which works well : using ExcelInterop =...
4
by: wellscrambled | last post by:
Folks, Probably don't have the right forum here, but this is all a bit new to me. I have a web site that sends me a daily email with an excel spreadsheet attachment that contains some customer...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.