arjunpk -6 Light Poster

Hi,
I'm using microsoft.interop.excel to automate excel sheets....
here's a snippet from the original code.....

rangeTemp1 = "C" + rowNo;
rangeTemp2 = "C" + total;

worksheet.get_Range(rangeTemp1, rangeTemp2).Merge(false);
range = worksheet.get_Range(rangeTemp1, rangeTemp2);
range.FormulaR1C1 = temp.query;

i'm trying to insert a long string into the cell....
though manually i am able to insert it, when i try to automate it, it throws a com exception unhandled error in the last line of the above code....

The data that i'm trying to insert is the following....

"Select production_Node_Uid,Start_Date, DEFERMENT_UID, " 
+ " lip_duration as Planned_SD_DURATION, planned_sd_duration as Production_DURATION , productionnode AS  NodeShotName "
+ " from  " + Parameters!SchemaName.Value + ".RPT_AVAILABILITY_STATUS3 WHERE  1=1 "
+ IIF(UCase(Parameters!AREA_CODE.Value)="ALL",""," AND   AREA_CODE IN("+Parameters!AREA_CODE.Value+")")
+ IIF(UCase(Parameters!CLUSTER_CODE.Value)="ALL",""," AND CLUSTER_CODE="+"'"+Parameters!CLUSTER_CODE.Value+"'" )
+ IIF(Ucase(Parameters!LOCATION_CODE.Value)="ALL",""," AND  LOCATION_CODE="+"'"+Parameters!LOCATION_CODE.Value+"'")
+ IIF(UCase(Parameters!NODE_UID.Value)="ALL",""," AND  Production_Node_UID="+"'"+Parameters!NODE_UID.Value+"'")
+ "  AND Start_Date  >= To_Date("+"'"+Parameters!EVENTDATE_FROM.Value+"'"+ "," + "'MM/dd/yyyy HH24:MI:SS'" +")"
+ "  AND Start_Date <= To_Date("+"'"+Parameters!EVENTDATE_TO.Value+"'"+ "," + "'MM/dd/yyyy HH24:MI:SS'" +")"
+ "union "
+ "Select production_Node_Uid,Start_Date,  DEFERMENT_UID, "
+ " Planned_SD_DURATION, Production_DURATION,  NodeShotName "
+ " from  " + Parameters!SchemaName.Value + ".RPT_AVAILABILITY_STATUS_NULL  WHERE 1=1 "
+ IIF(UCase(Parameters!AREA_CODE.Value)="ALL",""," AND   AREA_CODE IN("+Parameters!AREA_CODE.Value+")")
+ IIF(UCase(Parameters!CLUSTER_CODE.Value)="ALL",""," AND CLUSTER_CODE="+"'"+Parameters!CLUSTER_CODE.Value+"'" )
+ IIF(Ucase(Parameters!LOCATION_CODE.Value)="ALL",""," AND  LOCATION_CODE="+"'"+Parameters!LOCATION_CODE.Value+"'")
+ IIF(UCase(Parameters!NODE_UID.Value)="ALL",""," AND  Production_Node_UID="+"'"+Parameters!NODE_UID.Value+"'")
+ "  AND Start_Date  >= To_Date("+"'"+Parameters!EVENTDATE_FROM.Value+"'"+ "," + "'MM/dd/yyyy HH24:MI:SS'" +")"
+ "  AND Start_Date <= To_Date("+"'"+Parameters!EVENTDATE_TO.Value+"'"+ "," + "'MM/dd/yyyy HH24:MI:SS'" +")"

i have attached the screenshot of the error message.....

Also, i have one more error in the following code.....
it does not throw an exception.... i'm trying to insert an image.....
but in the excel sheet it just displays as system.drawing.bitmap......
here is the code i'm using to insert the image....

range = (Excel.Range)worksheet.Cells[1, 1];

Image image = Image.FromFile("C:\\abc.PNG");
range.set_Item(1,1,image);

and one last thing....
how do i make the cells dynamically expand according to the text width.... i want the width of the cells to be the width of the headers for that cell.....