Issue
I'm generating HTML code for regular tables:
<table cellpadding="0" cellpadding="0">
<tr>
<td>Data</td>
<td>Data</td>
<td>Data</td>
<tr>
</table>
After generation, I open the HTML file in a browser (Firefox) and copy and paste into blank Google Doc, BUT Google Docs translates the table without borders borders and default format.
There is a way to format the HTML table to meed the Google Docs requirements? Or there is a way to format a lot of tables of a Google Doc using a macro ? (I mean table borders and single linespacing)
Solution
The first thing I notice is the <table>
has cellpadding="0"
declared on it, twice.
“Do not use [
cellpadding
orcellspacing
], as [they have] been deprecated. The element should be styled using CSS.” —MDN web docs
See this other StackOverflow question for how to set cellpadding and cellspacing in CSS.
This actually addresses your problem, as adding a border-collapse
property to your table
style will cause allow a table to paste into a Google Doc as a table… if you set it to separate
.
Or if you add padding
to your td
(and th
if you have them)
I should also note, different browsers will produce different results. I've also found how much is selected can effect how the table pastes in. My best advice is to experiment based on the look of your table and your desired result.
Answered By - VTRGnW2uxM
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.