当前位置: 代码迷 >> ASP.NET >> 用JS把页面导出EXCL后,数据前面的0被去掉了,怎么处理
  详细解决方案

用JS把页面导出EXCL后,数据前面的0被去掉了,怎么处理

热度:10189   发布时间:2013-02-25 00:00:00.0
用JS把页面导出EXCL后,数据前面的0被去掉了,怎么办?
我知道要设置单元格格式为文本但是用JS怎么设置?
我JS导出代码如下:

//指定页面区域内容导入Excel
function AllAreaExcel() 
{
var oXL = new ActiveXObject("Excel.Application"); 
var oWB = oXL.Workbooks.Add(); 
var oSheet = oWB.ActiveSheet; 
var sel=document.body.createTextRange();
sel.moveToElementText(PrintA);
sel.select();
sel.execCommand("Copy");
oSheet.Paste();
oXL.Visible = true;
}

------解决方案--------------------------------------------------------
HTML code
<html xmlns:v="urn:schemas-microsoft-com:vml"xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:x="urn:schemas-microsoft-com:office:excel"xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"> </head><body link=blue vlink=purple><table cellpadding=0 cellspacing=0 border=0 width="100%">     <tr>        <td align="left"  class="Xtd1" style="">7</td>        <td align="left"  class="Xtd2" style="" x:str>CG0101&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>M&nbsp;</td>        <td align="left"  class="Xtd2" style="color:red" x:str>0000110029331(零还在)</td>        <td align="left"  class="Xtd2" style="" x:str>0000110029331</td>        <td align="right" class="Xtd2" style="">1</td>        <td align="right" class="Xtd2" style="">8.50</td>        <td align="left"  class="Xtd2" style="" x:str>OW00000888          &nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>洪記&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>NIL&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>PRHK11090851&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>NIL&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>China&nbsp;</td>    </tr>               <tr>        <td align="left"  class="Xtd1" style="">8</td>        <td align="left"  class="Xtd2" style="" x:str>CG0101&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>M&nbsp;</td>        <td align="left"  class="Xtd2" style="color:red" x:str>0000256</td>        <td align="left"  class="Xtd2" style="" x:str>CONN-TEK(仲駿)&nbsp;</td>        <td align="right" class="Xtd2" style="">3</td>        <td align="right" class="Xtd2" style="">13.30</td>        <td align="left"  class="Xtd2" style="" x:str>0084771754          &nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>洪記&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>NIL&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>PRHK11090778&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>NIL&nbsp;</td>        <td align="left"  class="Xtd2" style="" x:str>China&nbsp;</td>    </tr>   </table></body></html>