Currently, I have the following method that writes to excel 2007.
public static void createSpreadsheet(String msg)
{
Excel.Application oXL;
Excel.Workbook oWB;
Excel.Worksheet oSheet;
Excel.Range oRng;
oXL = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
oWB = oXL.Workbooks.get_Item(1);
oSheet = (Excel.Worksheet)oWB.ActiveSheet;
oXL.Visible = true;
oXL.UserControl = false;
oRng = oSheet.get_Range("A1", "A" + 1);
oRng.Value2 = msg;
}
However, whatever msg I sent, it only get to write to column A1 which is evident from the code above.
How do I expand the code above so that whenever additional messages are sent, they are appended below the previously written column.??
In a console app, I could do this: Console.writeline(msg). How do I achieve that in excel?
Eg: Msg 1 (Col A1)
Msg 2 (Col A2)
Msg 3 (Col A3)
….
Define a variable called
currentColumnand pass it to the method:In calling: