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.
Code to write image to excel.
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
ronik
0 points
N/A
#130454
Code to write image to excel.
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.
Â
Â
Code to write image to excel.
  $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);
Code to write image to excel.
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.