c# - excel - interop - numberformat

G

Guest

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#
Code:
using System;
using Excel;

namespace ConsoleApplication1 {
class Class1   {
[STAThread]
static void Main(string[] args) {
Excel.Application app = new Excel.Application();
app.Visible = true;
try {
app.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
_Worksheet worksheet = (_Worksheet) app.ActiveSheet;
if (worksheet == null) {
Console.WriteLine ("ERROR: worksheet == null");
}
Console.WriteLine("Numberformat:"+app.ActiveCell.NumberFormat);

Console.WriteLine("NumberformatLocal:"+app.ActiveCell.NumberFormatLocal);
} catch (Exception e) {
Console.Out.WriteLine(e);
}
app.Quit();
}
}
}

---------------------------------------------
VBA
Code:
Sub test()
Debug.Print "Numberformat:" & ActiveCell.NumberFormat
Debug.Print "NumberformatLocal:" & ActiveCell.NumberFormatLocal
End Sub
 
A

Alvin Bruney [MVP]

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
 

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

Top