我有一个使用php.Now代码导出excel的表单,运行良好,但所有列似乎都相同宽度。我想设置列宽度,但我如何设置that.here是我的代码
<form style="display:none" id="sendtable" action="<?php echo PRODUCTS . 'downloadexcel' ?>" method="post">
<input type="button" name="Export Excel"
value="Export Excel" onclick="callexports();"/>
<div id="tabledata">
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
table#t01 {
width: 100%;
background-color: #f1f1c1;
}
</style>
</head>
<body>
<table style="width:100%">
<!-- Column 1 -->
<colgroup width="80%" style="background-color: green;">
<!-- Column 2 -->
<colgroup width="80%" style="background-color: red;">
<tr>
<th>#</th>
<th>Action Items</th>
<th>Assigned to</th>
<th>Start date</th>
<th>End date date</th>
</tr>
<tr>
<?php
if (isset($this->getallactionitems)):
$i = 1;
foreach ($this->getallactionitems as $details):
?>
<td><?php echo $i; ?></td>
<td style="width: 80%;">
<?php echo $details['Actions']?></td>
<td><?php echo $details['Assigned_to'] ?></td>
<td><?php echo $details['Start_date'] ?></td>
<td><?php echo $details['End_date'] ?></td>
</tr>
<?php $i++ ?>
<?php endforeach;
endif; ?>
</tr>
</table>
<br>
</body>
<input type="hidden" name="tableval" id="tableval" />
</form>函数下载:
public function downloadexcel() {
$filename = "Actionitems" . time(); //File Name
$file_ending = "doc";
//header info for browser
header("Content-type:application/vnd.msword");
// header("Expires:0");//no cache
// header("Cache-Control:must-revalidate,post-check=0,pre-check=0");//no cache
// header("content-disposition:attachment;filename=sampleword.xlxs");
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
Echo $_REQUEST['tableval'];
}我想用这个code.Now来设置B列的宽度所有的列宽看起来是一样的width.How来设置列宽?请帮助我。
发布于 2018-01-19 15:02:27
你应该看看这个包,它非常适合处理excel文件,并且它有很好的文档。您不必构建自己的excel文件,只需将数据作为数组传递给库即可。
https://stackoverflow.com/questions/48335534
复制相似问题