简体   繁体   中英

Google docs post table from textarea

I have created a textarea field in my google apps spreadsheet table.html.

<textarea  name="tableS" id="tableS"></textarea>

Also i make a function which place table in HTML format to this texarea

        function updateUrl(myArray) {
            var results, tr, td;
            results = "<table border=\"1\" style=\"table-layout: fixed; width: 100%\">";
            for (var i = 1, len = myArray.length; i < len; i++) {
                tr = myArray[i];
                results += "<tr>";
                for (var y = 0, leng = tr.length; y < leng; y++) {
                    td = tr[y];
                    results += "<td>" + td + "</td>";
                }
                results += "</tr>";
            }
            results += "<\/table><br \/> <br \/>";

            document.getElementById("tableS").value = results;
}

Then i trying to replace on submit predefined text in my google docs template with textarea tables as html,

copyBody.replaceText('Passwords', e.table);

but i get in template pure text with tags

在此处输入图片说明

, but i need to get table formatted as html

在此处输入图片说明

How to do that?

You would need to convert the HTML to an image, and then insert the image. You can't put HTML markup directly into a Google Doc, and have it be rendered. You are creating a table with HTML, but you can create a table for a Google Doc with the Document and Table class and sub class.

Google Documentation - Table

So, don't use HTML. It won't work. Use the Table class, build a table with the Table methods, then insert a Table into the Doc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM