FcoLomas

Hi all!!

Me one more time...

Well I haven't see before this behavior, I have an Excel sheet that recives data from a Database, of course with VSTO 2005, some of this data are Excel's formulas, well if the cell is formated as text it don't uses the formula and no calc is performed, but if the cell is formatted as general it works well, the question here is:

I'm using C# with an Excel SmartDoc, when I put the database value on the cell I'm changing the NumberFormat property to "General", but when I review the cell's format it has no change...

Someone has any idea




Re: Visual Studio Tools for Office Excel Cell Format Behavior

Cindy Meister

Hi Francisco

A couple of follow-up questions:

1. Are you sure the text "formatting" is set at the cell level using the equivalent of Format/Cell Or is it possible the text formatting has been set through the equivalent of Data/Text to Columns These two work at very different levels; the first is just UI, the second is at the database level of the workbook. Are you able to get a formula to work by changing to "general" using Format/Cell in the UI

2. Please show us the code that's "not working"






Re: Visual Studio Tools for Office Excel Cell Format Behavior

FcoLomas

Well as you said when you change the format from text to general the formula is processed, but if I use it as a workaround in my code the format is not changed, the code is:

rngWrite = (Range)wksActual.get_Range(strCol + intRow.ToString(), Type.Missing);
rngWrite.NumberFormat = "General";
rngWrite.Value2 = "=sum(a1:a45)";

The format of the cell is Text, then try to change it and voila!!!
Some useful information: the code is good one time, later doesn't work, but you restart your machine and have one more chance!!






Re: Visual Studio Tools for Office Excel Cell Format Behavior

Andrew Whitechapel - MSFT

Francisco, you probably need to supply a bit more context.

I've just tried your exact code listed above, and it works fine for me, every time.





Re: Visual Studio Tools for Office Excel Cell Format Behavior

Andrew Whitechapel - MSFT

As we haven't heard anything more for a while, I'm assuming you got your code to work, and the issue is resolved. So, I'm closing this post.

If the problem resurfaces, or you have any other problem, please open a new post, with the background information and details of the problem. Thanks.





Re: Visual Studio Tools for Office Excel Cell Format Behavior

FcoLomas

Thanks to all!!!

Really it disappear, I really don't know why but maybe I guess that someone in the team was doing something wrong and corrects it...

Thanks for your time!!