将HTML表格导出到MSWord

将HTML表格导出到MSWord,html,ms-word,html-table,Html,Ms Word,Html Table,我有一个html文件,其中有一个表正在转换为.doc 我已经能够让文档在“打印视图”中自动打开 问题是这张桌子太大,放不下这一页。我已经将宽度设置为100%,但是word默认选中了“允许表格扩展到边距”选项。我想以类似于将视图设置为“打印”的方式将其设置为“未选中” 以下是我正在使用的模板: <html xmlns:w="urn:schemas-microsoft-com:office:word"> <head> <!--[if gte mso 9]>

我有一个html文件,其中有一个表正在转换为.doc
我已经能够让文档在“打印视图”中自动打开

问题是这张桌子太大,放不下这一页。我已经将宽度设置为100%,但是word默认选中了“允许表格扩展到边距”选项。我想以类似于将视图设置为“打印”的方式将其设置为“未选中”

以下是我正在使用的模板:

<html xmlns:w="urn:schemas-microsoft-com:office:word">
<head>
<!--[if gte mso 9]>
  <xml>
    <w:WordDocument>
      <w:View>Print</w:View>
      <w:DoNotOptimizeForBrowser/>
    </w:WordDocument>
  </xml>
<![endif]-->
<style type="text/css">
  <%= global_style %>
  <%= report_style %>
</style>
</head>
<body>
<div id="word-export" class="WordSection1">

文档提到了一些关于“w:GrowtoFit”的东西,但如果这能起作用,我不知道如何使它“虚假”。



找到了!您必须使用w:Compatibility和w:dontGrowtAutoFit。有趣的是,在GrowtAutoFit文档附近没有引用DontGrowtAutoFit

<html xmlns:w="urn:schemas-microsoft-com:office:word">
<head>
<!--[if gte mso 9]>
  <xml>
    <w:WordDocument>
      <w:View>Print</w:View>
      <w:DoNotOptimizeForBrowser/>
      <w:Compatibility>
        <w:DontGrowAutofit/>
      </w:Compatibility>
    </w:WordDocument>
  </xml>
<![endif]-->
<style type="text/css">
  <%= global_style %>
  <%= report_style %>
</style>
</head>
<body>
<div id="word-export" class="WordSection1">

找到了!您必须使用w:Compatibility和w:dontGrowtAutoFit。有趣的是,在GrowtAutoFit文档附近没有引用DontGrowtAutoFit

<html xmlns:w="urn:schemas-microsoft-com:office:word">
<head>
<!--[if gte mso 9]>
  <xml>
    <w:WordDocument>
      <w:View>Print</w:View>
      <w:DoNotOptimizeForBrowser/>
      <w:Compatibility>
        <w:DontGrowAutofit/>
      </w:Compatibility>
    </w:WordDocument>
  </xml>
<![endif]-->
<style type="text/css">
  <%= global_style %>
  <%= report_style %>
</style>
</head>
<body>
<div id="word-export" class="WordSection1">