Generate C# code from Excel file (2007)

  • Thread starter Thread starter Luigi
  • Start date Start date
L

Luigi

Hi all,
is it possible to create an Excel formula (or something else) that, from the
name of a cell (i.e "Cell Name 1"), it create me a string like:

public const string Cell_Name_1 = "Cell_Name_1";

and this for every cells in the sheet, so I can obtain:

public const string Cell_Name_1 = "Cell_Name_1";
public const string Cell_Name_2 = "Cell_Name_2";
public const string Cell_Name_3 = "Cell_Name_3";
----etc------

Thanks in advance.
 
Hi,

in column B place the needed numbers, say B2 = 1, B3 = 2 etc.
In column C place the formula ="public const string Cell_Name_" & B2 & " =
""Cell_Name_" & B2 & """;"

If B2 contains 1 the result in C2 will be
public const string Cell_Name_1 = "Cell_Name_1";

maybe you'll have to play al little with the " and ' depending on your
international settings (maybe you don't)

Hope this helps.

Carl
 
Carl Willems said:
Hi,

in column B place the needed numbers, say B2 = 1, B3 = 2 etc.
In column C place the formula ="public const string Cell_Name_" & B2 & " =
""Cell_Name_" & B2 & """;"

If B2 contains 1 the result in C2 will be
public const string Cell_Name_1 = "Cell_Name_1";

maybe you'll have to play al little with the " and ' depending on your
international settings (maybe you don't)

Hope this helps.

Hi Carl,
thanks a lot.
Another question: in the last cell I have to concatenate all cells, and I'm
using the & operator.
But in this way I must write
=F10&F11&F12&F13&......etc

and I have hundreds of cells.
Is there a way to write only the firt and the last cell?

Luigi
 
Back
Top