2

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 Jan 11 '18 at 16:42
  • @aman6496 i provided a c# script task code, you ignored my answer and asked the same question again!! – Hadi Jan 15 '18 at 21:24
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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.