Google Docs在很多方面都是一个非常灵活的文字处理器,但是很多人没有意识到您可以将HTML嵌入到Google文档中。
有几种方法可以做到这一点。一种是直接从浏览器中复制HTML文档并将其粘贴到Google Doc中。另一个技巧是使用Google 表格中的(Google Sheets)importHTML函数来自定义HTML格式,然后您可以将其嵌入到Google文档中。
将 HTML 页面嵌入到 Google 文档中(Embed HTML Page Into a Google Doc)
如果您正在编写需要来自网络的信息的文档,那么您要做的最后一件事就是将该信息粘贴为文本。
这是因为大多数在线信息都包含图表、图形(charts, graphs)、图像等信息。例如,如果您可以将HTML嵌入到来自网页的Google文档中,那么为研究论文做笔记会容易得多。(Google)
值得庆幸的是,在Google Docs中执行此操作非常容易。Google Docs会自动插入粘贴的网页以尽可能多地包含原始格式,这使得它变得简单。
- 突出显示(Highlight)要嵌入到文档中的网页部分。按键盘上的 Ctrl-C(Press Ctrl-C)复制该部分。
上面的示例显示了从Wikipedia复制和粘贴页面部分的过程。
- 接下来,打开要嵌入该HTML页面的(HTML)Google文档,右键单击,然后选择粘贴(Paste)。确保选择Paste而不是Paste without formatting。
- 当您选择粘贴(Paste)时,Google Docs将自动导入您复制的页面部分,尽可能以原始页面上显示的格式导入。这包括图像、URL链接和标题。
您可以通过将鼠标悬停在一个链接上来查看链接。在Google Docs中,您会看到外部链接出现。
您可能会发现在某些情况下,图像格式(例如页面上的对齐)与您复制的原始页面不完全匹配。
您可以通过选择图像、选择功能区中的左对齐文本图标以及图像下方的环绕文本图标来解决此问题。
这应该看起来更像原始网页格式。如果图像有标题,您可能需要将其向下移动到图像下方,或任何您认为合适的位置。
如您所见,使用从网络复制和粘贴的方式将HTML嵌入到Google 文档(Google Doc)中并不完美。但这是在尽可能多地保留原始网页HTML格式的同时传输信息的最快方式。
使用 importHtml 将 HTML 嵌入 Google Doc(Embed HTML Into Google Doc With importHtml)
将HTML(HTML)嵌入到Google文档中的另一种方法是使用 importHtml 函数将HTML嵌入到Google 表格中。(Google Sheets)然后您可以将其插入到Google Docs中。
请记住,此函数不是嵌入页面的一部分,而是插入整个页面。但是,可以通过在函数语法中使用索引号来仅从页面导入表或列表来解决此问题。
例如,假设您想嵌入维基百科(Wikipedia)网页中关于美国(United) 人口统计的第四个表格。(States)首先(First),打开一个新的Google 表格(Google Sheets)电子表格。在电子表格的第一个单元格中,键入函数:
=ImportHTML("https://en.wikipedia.org/wiki/Demographics_of_the_United_States", "table", 4)
当您按下 Enter 时,这将从网页中导入第四个表格并将其插入到您光标所在的表格中。
现在您已经导入了可用于嵌入Google Docs的(Google Docs)HTML数据。格式化(Format)此表,但您希望它在Google Docs中查看。
- 为此,请在Google 表格(Google Sheets)中突出显示该表格,然后按Ctrl-C复制该表格。
- 将光标放在要放置表格的Google 文档(Google Docs)文档中,单击鼠标右键,然后选择粘贴(Paste)。
- 您将看到一个带有几个选项的窗口弹出窗口。选择链接到电子表格(Link to spreadsheet),然后选择粘贴(Paste)按钮。
这会将Google 表格(Google Sheets)中的表格完全按照其最初的格式插入到Google 文档中。(Google Docs)
通过链接表格,您可以随时更新Google Sheets中的表格,它会自动更新Google Docs中的表格。
使用 Word 在 Google 文档中嵌入 HTML(Embed HTML in Google Docs Using Word)
如果您将简单的 HTML 代码(simple HTML code)保存到 .html 或 .htm 文件中,则可以先在Microsoft Word中打开它。Word总是尝试呈现 HTML 文件(render an HTML file)。然后,您可以将此文档导入Google 文档(Google Docs),并将整个页面或页面的部分复制到您正在编辑的文档中。
- 为此,请打开Microsoft Word并打开您的HTML文件。您应该会看到文件呈现在浏览器中的样子。
- 将此文档保存为 Word 格式。
- 然后,返回Google Drive并将文件上传到您的Google Drive帐户。
- 上传后,右键单击它并选择Open with,然后选择Google Docs。
这将以Google Docs格式打开文档,格式尽可能接近HTML呈现。
现在您可以复制整个HTML文件,也可以只复制您想要的部分。然后将其粘贴到您正在编辑的Google Docs文档中。(Google Docs)
您可以通过以下三种方式将HTML嵌入到Google文档中。您选择的选项取决于您可用的工具。它还取决于您是想要整个页面,还是只需要一个部分,以及您需要与原始HTML呈现格式匹配的程度。
How To Embed HTML Into a Google Doc
Google Docs is a very flexible word processor in many ways, but what many people don’t realize is that you can embed HTML into а Google doc.
There are several ways to do this. One is to actually copy an HTML document straight from a browser and paste it into a Google Doc. The other is a trick using the importHTML function in Google Sheets to customize HTML formatting that you can then embed into a Google document.
Embed HTML Page Into a Google Doc
If you’re writing a document that requires information from the web, the last thing you want to have to do is paste that information as text.
This is because most information online contains information like charts, graphs, images and more. For example, taking notes for researching an essay paper would be much easier if you could embed HTML into a Google doc from a web page.
Thankfully, doing this in Google Docs is very easy. It’s made simple by the fact that Google Docs will automatically insert pasted web pages to include the original formatting, as much as possible.
- Highlight the section of the web page that you want to embed into your document. Press Ctrl-C on the keyboard to copy that section.
The example above shows the process of copying and pasting a section of a page from Wikipedia.
- Next, open the Google doc where you want to embed that HTML page, right-click, and select Paste. Make sure to select Paste and not Paste without formatting.
- When you select Paste, Google Docs will automatically import the page section you copied as much as possible in the format it appears on the original page. This includes images, URL links, and headers.
You can see that the links are live by hovering over one. In Google Docs you’ll see the external link appear.
You may find that in some cases the image formatting (such as alignment on the page) doesn’t match perfectly with the original page you copied from.
You can fix this by selecting the image, selecting the left align text icon in the ribbon, and the wrap text icon under the image.
This should appear more like the original web page formatting. If the image had a caption, you may need to move it down under the image, or wherever else you feel is appropriate.
As you can see, embedding HTML into a Google Doc using copy and paste from the web isn’t perfect. But it’s the fastest way to transfer information while retaining as much of the original web page HTML formatting as possible.
Embed HTML Into Google Doc With importHtml
Another method to embed HTML into your Google document is by embedding the HTML into Google Sheets using the importHtml function. Then you can insert that into Google Docs.
Keep in mind that instead of embedding a section of the page, this function will insert the entire page. However, there’s a way around that by using an index number in the function syntax to import only a table or list from the page.
For example, say you want to embed the fourth table from the Wikipedia web page about United States demographics. First, open a new Google Sheets spreadsheet. In the first cell of the spreadsheet, type the function:
=ImportHTML("https://en.wikipedia.org/wiki/Demographics_of_the_United_States", "table", 4)
When you press Enter, this will import the fourth table from the web page and insert it into the table where your cursor is.
Now you have the imported HTML data you can use to embed inside Google Docs. Format this table however you’d like it to look inside Google Docs.
- To do this, highlight the table in Google Sheets and press Ctrl-C to copy the table.
- Place the cursor in your Google Docs document where you want to place the table, right-click, and select Paste.
- You’ll see a window pop-up with a couple of options. Select Link to spreadsheet and select the Paste button.
This inserts the table from Google Sheets into Google Docs exactly the way it’s originally formatted.
By linking the table, you could always update the table in Google Sheets and it’ll automatically update the table in Google Docs.
Embed HTML in Google Docs Using Word
If you have your simple HTML code saved into a .html or .htm file, you can open it in Microsoft Word first. Word always attempts to render an HTML file. Then you can import this document into Google Docs and copy the entire page or section of the page into the document you’re editing.
- To do this, open Microsoft Word, and open your HTML file. You should see the file rendered the way it would look inside a browser.
- Save this document in Word format.
- Then, return to Google Drive and upload the file to your Google Drive account.
- Once it’s uploaded, right click on it and select Open with, and select Google Docs.
This will open the document in Google Docs format, formatted as close to the HTML rendering as possible.
Now you can copy either the entire HTML file, or just the section you want. Then paste it into the Google Docs document that you’re editing.
These are three ways you can embed HTML into a Google doc. The option you choose depends what tools you have available. It also depends whether you want the entire page, or just a section and how closely you need the original HTML rendered formatting to match.