使用PhpSpreadsheet将CSV文件转换为HTML文档时,删除所有样式和格

时间:2019-12-06 15:13:04

标签: html css csv phpspreadsheet

使用PhpSpreadsheet将CSV文件转换为HTML文档时,请删除所有样式和边界。

大家好,

我正在尝试将CS​​V文件转换为HTML表。它运行正常,只是HTML文档获得了很多内联CSS。 像这样:

  <style type="text/css">
    html { font-family:Calibri, Arial, Helvetica, sans-serif; font-size:11pt; background-color:white }
    a.comment-indicator:hover + div.comment { background:#ffd; position:absolute; display:block; border:1px solid black; padding:0.5em }
    a.comment-indicator { background:red; display:inline-block; border:1px solid black; width:0.5em; height:0.5em }
    div.comment { display:none }
    table { border-collapse:collapse; page-break-after:always }
    .gridlines td { border:1px dotted black }
    .gridlines th { border:1px dotted black }
    .b { text-align:center }
    .e { text-align:center }
    .f { text-align:right }
    .inlineStr { text-align:left }
    .n { text-align:right }
    .s { text-align:left }
    td.style0 { vertical-align:bottom; border-bottom:none #000000; border-top:none #000000; border-left:none #000000; border-right:none #000000; color:#000000; font-family:'Calibri'; font-size:11pt; background-color:white }
    th.style0 { vertical-align:bottom; border-bottom:none #000000; border-top:none #000000; border-left:none #000000; border-right:none #000000; color:#000000; font-family:'Calibri'; font-size:11pt; background-color:white }
    table.sheet0 col.col0 { width:42pt }
    table.sheet0 col.col1 { width:42pt }
    table.sheet0 col.col2 { width:42pt }
    table.sheet0 col.col3 { width:42pt }
    table.sheet0 col.col4 { width:42pt }
    table.sheet0 col.col5 { width:42pt }
    table.sheet0 col.col6 { width:42pt }
    table.sheet0 col.col7 { width:42pt }
    table.sheet0 col.col8 { width:42pt }
    table.sheet0 col.col9 { width:42pt }
    table.sheet0 col.col10 { width:42pt }
    table.sheet0 col.col11 { width:42pt }
    table.sheet0 col.col12 { width:42pt }
    table.sheet0 col.col13 { width:42pt }
    table.sheet0 tr { height:15pt }
  </style>
</head>

我正在做下一件事:

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($filename);

$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);

$writer->save($fileSave);

如何仅获取没有标记的纯HTML表? .CSV不包含任何CSS /标记

0 个答案:

没有答案
相关问题