问题
I found javascript solution for removing gridlines on Google docs spreadsheets (using "download as HTML" and then past javascript in Web Address Bar): works great !!
javascript:var v="none",e="defaultView",o="border",m="Color",w=function(a,b){if(document[e]){if(document[e].getComputedStyle(a,null)[o+b+m]=="rgb(204, 204, 204)")a.style[o+b]=v}else if(a.currentStyle[o+b+m]=="#ccc")a.style[o+b]="none"},q=function(a){a=window.document.getElementsByTagName(a);for(var b=0;b<a.length;b++){var c=a[b];w(c,"Left");w(c,"Right");w(c,"Bottom");w(c,"Top")}};q("td");q("table");
Was wondering if it is possible to make a comparable javascript to remove the header and footer for docs "publised" to the web?! Published spreadsheets have a -> header: filename + sheetname; -> footer: "Edit this page (if you have permission) – Published by Google Docs – Report Abuse – Updated automatically every 5 minutes" -> example: TEST (I already added "&gridlines=false" to the url to remove gridlines).
Why is previous solution not sufficient ?! I want some people to view and print the result of a spreadsheet (via publish to web) without giving them access (view) to the spreadsheet itself. Therefore they can't use "download as HTML" + your javascript, but want to provide a url to view a published site and be able to make a neat print without the Google header and footer.
Would be great if anyone could help out!
Regards,
回答1:
Thankfully the layout on this page is super simple.
<div id="header">...</div>
<div id="content">...</div>
<div id="footer">...</div>
You could write a function like this to hide the header and footer.
var f = function(id)
{
document.getElementById(id).style.display = "none";
};
f("header");
f("footer");
Or the copy paste version:
javascript:var f=function(id){document.getElementById(id).style.display="none";};f("header");f("footer");
回答2:
I built an app that does just this + improves the default layout. Check it out: http://gdoc.pub
回答3:
You can use the range
parameter to get rid of the headers and footers, as described here.
来源:https://stackoverflow.com/questions/2123764/remove-header-footer-from-published-google-docs-spreadsheet