dtmsaqtly798322992 2015-05-25 08:47
浏览 425

通过javascript将表格html导出为文本和图像

my problem is images !!!! i export table this table html to excel but the images aren't exported in the table .

   <table class="order-table table sortable" id="tableadmin">
    <thead>
        <tr>
            <th style="width:8px; min-width:8px; max-width:8px;">ID</th>
            <th>Télépro</th>
            <th>Date RDV</th>
            <th>Heure RDV</th>
            <th>Fiche</th>
            <th style="width:170px; min-width:170px; max-width:170px;">Compterendu</th>
            <th style="width:250px; min-width:250px;">Commentaire commercial</th>
        </tr>
    </thead>
    <tbody id="changetable" class="new">
        <tr>
            <td>
                <?php echo $id ?>
            </td>
            <td>
                <?php echo $login ?>
            </td>
            <td>
                <?php echo $date ?>
            </td>
            <td>
                <?php echo $heure ?>
            </td>
            <td><img src="../img/fiche.png" />
            </td>
            <td>
                <?php echo $compterendu ?>
            </td>
            <td>
                <?php echo $comment ?>
            </td>
        </tr>
    </tbody>
</table>

my problem is images !!!!

  • 写回答

2条回答 默认 最新

  • dongren1353 2015-05-25 09:08
    关注

    Writing images to the excel sheet using phpexcel class is a great feature , using this method we can draw the images inside the excel column it looks good and nice to have images with some descriptions.

    While working on an Import/Export system I have noticed this facility of PHPExcel its really good and easy, Ok lets check the code for writing images to the excel sheet using PHPExcel.

    include 'PHPExcel.php';
    // Create new PHPExcel object
    $objPHPExcel = new PHPExcel();
    // Set properties
    $objPHPExcel->getProperties()->setCreator("Jobin Jose");
    $objPHPExcel->getProperties()->setLastModifiedBy("Jobin Jose");
    $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
    $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
    $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHPExcel classes.");
    // Add some data
    // echo date('H:i:s') . " Add some data
    ";
    $objPHPExcel->setActiveSheetIndex(0);
    $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Hello');
    $objPHPExcel->getActiveSheet()->SetCellValue('B2', 'world!');
    //$objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Hello');
    $objPHPExcel->getActiveSheet()->SetCellValue('D2', 'world!');
    $objPHPExcel->getActiveSheet()->setTitle('Simple');
    $gdImage = imagecreatefromjpeg('uploads/t12.jpg');
    // Add a drawing to the worksheetecho date('H:i:s') . " Add a drawing to the worksheet
    ";
    $objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
    $objDrawing->setName('Sample image');
    $objDrawing->setDescription('Sample image');
    $objDrawing->setImageResource($gdImage);
    $objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
    $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
    $objDrawing->setHeight(150);
    $objDrawing->setCoordinates('C1');
    $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
    // Echo done
    echo date('H:i:s') . " Done writing file.
    ";
    The out put will be like as follows.
    

    Writing Images to Excel Using PHPExcel enter image description here

    The above code will create an “xlsx” formatted file because it uses 2007 excel classes If you want “xls” format just try with 2005 class do not for get to change the file format to “xls” while using 2005.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大