I am exporting excel sheets through SSIS export, and creating excel sheet at run time using execute sql task. Now the client needs a logo(image) to be attached to the excel sheet on top of data part. Do we have any way out to do that.
NB: we cannot use "file system task" to copy a pre-existing excel file as we have to create the task on runtime. cannot copy a excel sheet from any other location.
Thanks
-
You can use a script task in ssis and write a VBA code to insert the logo to the cell.samosql– samosql2018年01月11日 16:42:29 +00:00Commented Jan 11, 2018 at 16:42
-
@aman6496 i provided a c# script task code, you ignored my answer and asked the same question again!!Hadi– Hadi2018年01月15日 21:24:59 +00:00Commented Jan 15, 2018 at 21:24
1 Answer 1
You can use a script task to achieve that, you can benefit from the Microsoft.Interop.Excel
library to achieve that, you can copy the image from a file using the following code:
Image ExcelImage = Image.FromFile(strFilePath);
System.Windows.Forms.Clipboard.SetDataObject(ExcelImage ,true);
And paste it to excel sheet using the following code:
Excel.Worksheet ThisSheet = (Excel.Worksheet)ThisWorkBook.Sheets[1];
Excel.Range oRange = (Excel.Range)ThisSheet.Cells[10,1];
ThisSheet.Paste(oRange,ExcelImage);
Detailed code provided in the following link:
Explore related questions
See similar questions with these tags.