在Excel中打开时强制html excel文件的宽度为一定宽度

发布于 2024-11-30 15:05:48 字数 374 浏览 0 评论 0原文

我在设置 html Excel 文件中的宽度然后在 Excel 中打开它时遇到问题。

当使用主要浏览器查看时,宽度在 html 中工作得很好,但是当加载到 Excel 中时,我发现有很大的脱节。

我与其他设计师交谈,他们说在 Excel 中使用网页预览技术,但这也不起作用。另一个人建议使用 col 标签并设置属性宽度、样式宽度和样式 mso 替代宽度。此外,还建议使用 span,并将表格宽度与 td 宽度之和相匹配,这在 Excel 中也不起作用,但它们似乎在所有浏览器中都工作得很好。

有多个桌子,每个桌子的宽度和高度都经过定制。

另外,我尝试将所有内容都放在一个表下,并仅设置第一行的宽度,但这也不起作用。我应该直接切换到pdf吗?

谢谢, 马克

I am having trouble setting the width in an html excel file and then opening it in excel.

The width works perfectly in html when viewed with the major browsers, but when loaded into excel I see a big disconnect.

I spoke with other designers and they said to use the web preview technique in excel, but that is not working either. Another person suggested using the col tag and setting the attribute width, style width, and the style mso alternate width. Also it was suggested to use span, and match table width to the sum of td width which also is not working in excel, but they all seem to work great in all the browsers.

There are multiple tables, and each table has been customized for width and height.

Also I have tried to put everything under one table and set only the first row for widths which is also not working. Should I just switch to pdf.

Thanks,
Marc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

幼儿园老大 2024-12-07 15:05:48

我能够通过在 Excel 中加载文件,手动调整所有列和高度,重新保存为 html,然后将文件重新显示为 html,然后将文件加载到 Excel 中来解决此问题。由于我的原始 html 有某些 css 样式,我必须重新应用这些样式,但格式宽度和高度是完美的。

这种技术唯一真正的问题是它可能需要花费很多时间才能按照您想要的方式获得 html 格式。我可能更快地只保存 xml,然后从 xml 转换为 html。

I was able to fix this by loading the file in excel, adjusting all the columns and heights manually, resaving into html, and then redisplaying the file as html, and then loading the file into excel. Since my original html has certain css styles, I had to re-apply those, but the formatting widths and heights were perfect.

The only real problem with this technique is it can take a lot of time to get the formatting in html just the way you want it. I may have been faster to just save a xml, then convert from the xml into html.

狼亦尘 2024-12-07 15:05:48

仅供参考,我遇到了同样的问题 - 无法强制保存为 XLS 的 HTML 中第一列的宽度。我也在使用
实际上,我可以将列大小设置为更大的值,例如 50px 或 100px,但无法将其设置为低于 25-30px 的最小阈值(我需要 1px)。

事实证明,造成这种混乱的原因是所使用的 HTML 文件的内容周围有另一个标签 - 当我删除它并只留下单个标签时,所有标签都开始正常工作。

FYI, I had the same issue - not being able to force the width to 1st column in HTML saved as XLS. I was using <td width="123"> too.
Actually, I was able to set the column size to some bigger value, like 50px or 100px, but couldn't set it below some minimum threshold of maybe 25-30px (I needed 1px).

It turned out that the cause for this confusion was that the content of used HTML file had another tag wrapped around it - when I removed it and left just single all started working well.

冷心人i 2024-12-07 15:05:48

如果您需要生成格式良好的 Excel 文件。 html excel 文件可能是一个糟糕的选择。

我最终的选择是:使用HtmlAgilityPack加载html到DocumentNode树,使用POI根据节点树创建行和单元格。

If you need to generate a well-formmatted excel file. html excel file might be a bad choice.

My final choice is: use HtmlAgilityPack to load html to DocumentNode tree, use POI to create rows and cells according to the node tree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文