Code to write image to excel.

Asked By 0 points N/A Posted on -
qa-featured

Hello all,

I developed a code to write data into cell, this is the code:

Excel. Application oAppln = new Excel. Application ();

Excel.Workbook oWorkBook = (Excel.Workbook)(oAppln.Workbooks.Add(@"D:workabcd.xls"));

Excel.Worksheet oWorkSheet = (Excel.Worksheet)oWorkBook.ActiveSheet;

oWorkSheet.Cells[1,1] = img;

Now I need help in getting code to write image to excel file, please.

SHARE
Best Answer by ronik
Answered By 10 points N/A #130452

Code to write image to excel.

qa-featured

Dear Judith,

You can write image to the excel file. I am providing you with some links that have codes of similar nature on them.

These codes work and would help you solve your problem regarding images.

PHP code can insert image to excel file and open it correctly in MS Excel?

How to Write image in excel sheet in asp.net?

Write Image in Excel file using PHP

Regards,

William S Snell.

Answered By 10 points N/A #130453

Code to write image to excel.

qa-featured

Hello, JudithLBarton

For adding a picture use the following 

xlWorkSheet.Shapes.AddPicture("C:xl_pic.JPG", _

Microsoft.Office.Core.MsoTriState.msoFalse, _

Microsoft.Office.Core.MsoTriState.msoCTrue, 50, 50, 300, 45)

if you have still facing a problem then you more.have to check the below links, that will help you

http://vb.net-informations.com/excel-2007/vb.net_excel_2007_insert_picture.htm

vb.net-informations.com/excel-2007/vb.net_excel_2007_tutorials.htm

Thanks,

Stella T Finley.

Best Answer
Best Answer
Answered By 0 points N/A #130454

Code to write image to excel.

qa-featured

Hi Judith,

Your code to write data into cell was good and here is the code to write image to excel file:
 
 $objDrawing = new PHPExcel_Worksheet_Drawing();    // Add a drawing to the worksheet
          $objDrawing->setWorksheet($objWorksheet);
          $objDrawing->setName(\"name\");                     // DEFINE NAME
          $objDrawing->setDescription(\"Description\");    // ADD DESCRIPTION
          $objDrawing->setPath(\'./path_to/image.png\');  //PATH OF THE SOURCE IMAGE
          $objDrawing->setCoordinates(\'B1\');                // Coordinates: The anchor cell which the upper left  corner of the drawing falls into e.g. 'A1'
 
          $objDrawing->setOffsetX(1);             //   OffsetX: Pixel offset to the right
          $objDrawing->setOffsetY(5);             //   OffsetY: Pixel offset downwards
 
If you need any further explanation with this code, just post here, happy to help.
 
 
Answered By 0 points N/A #130455

Code to write image to excel.

qa-featured

   $objDrawing = new PHPExcel_Worksheet_Drawing();
          $objDrawing->setWorksheet($objWorksheet);
          $objDrawing->setName("name");
          $objDrawing->setDescription("Description");
          $objDrawing->setPath('./path_to/image.png');
          $objDrawing->setCoordinates('B1');
          $objDrawing->setOffsetX(1);
          $objDrawing->setOffsetY(5);

Answered By 60 points N/A #130456

Code to write image to excel.

qa-featured

Hello,

In computer science, source code is any collection of computer instructions (possibly with comments) written using some human-readable computer language, usually as text. If you are used to using spreadsheets like Excel then it will be easy to read the code someone else wrote and write your own. If you do not know excel then you cannot write your own code. The spreadsheets provide opportunities for early learning-oriented coding as Microsoft Office.

Login/Register to Answer

Related Questions