473,397 Members | 2,084 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,397 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 14364
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

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.