Help Posting Tables

Let’s say I have a table in Google sheets that I want to post. I can hit the gear and build a table, but how do I simply copy and paste?

If I copy and paste using the preformatted text option I get a big jumbled mess.

	Coal	Natgas	"Other
Gas"	Nuclear	"Hydroelectric
Conventional"	Solar	"Renewable
Sources
Excluding
Hydroelectric and Solar"	Renewables
2018	1,149,487	1,471,843	13,463	807,084	292,524	63,825	350,467	414,292
2022	831,512	1,687,067	11,722	771,537	254,789	143,797	502,231	646,028
Change	-317,975	215,224	-1,741	-35,547	-37,735	79,972	151,764	231,736
% Change	-27.66%	14.62%	-12.93%	-4.40%	-12.90%	125.30%	43.30%	55.94%

Screen shot.
Crop.
Post as a jpg.

2 Likes

You can copy and paste directly from Excel and Google Sheets into the editing window. Or from a text editor. Discourse then automatically converts it into a table. It doesn’t always work, however. E.g. if you a have spurious tab or a mismatch somewhere, you’ll get the text as is instead, with tabs that are indistinguishable from spaces in the editor.

In your example it’s the header row that breaks things. For the conversion to work, every row needs to have the same number of columns, and for some reason the header has been split into multiple lines, breaking this criteria.

Also, note that the conversion won’t happen if you paste into a preformatted section. (I.e. ``` or <pre>.) In that case, the text along with tabs will be kept as is.

So, if you instead copy this

	Coal	Natgas	"Other Gas"	Nuclear	"Hydroelectric Conventional"	Solar	"Renewable Sources Excluding Hydroelectric and Solar"	Renewables
2018	1,149,487	1,471,843	13,463	807,084	292,524	63,825	350,467	414,292
2022	831,512	1,687,067	11,722	771,537	254,789	143,797	502,231	646,028
Change	-317,975	215,224	-1,741	-35,547	-37,735	79,972	151,764	231,736
% Change	-27.66%	14.62%	-12.93%	-4.40%	-12.90%	125.30%	43.30%	55.94%

and paste into the editing window (and not inside any ``` or <pre>), you should get a proper table:

Coal Natgas Other Gas Nuclear Hydroelectric Conventional Solar Renewable Sources Excluding Hydroelectric and Solar Renewables
2018 1,149,487 1,471,843 13,463 807,084 292,524 63,825 350,467 414,292
2022 831,512 1,687,067 11,722 771,537 254,789 143,797 502,231 646,028
Change -317,975 215,224 -1,741 -35,547 -37,735 79,972 151,764 231,736
% Change -27.66% 14.62% -12.93% -4.40% -12.90% 125.30% 43.30% 55.94%


If you want to try your luck with tabs and go for and old school table instead, you’ll need to use ``` or <pre> and copy and paste tabs to try to align the columns until it looks ok in the preview window. Tip: put ```text instead of ``` at the beginning of your section to get rid of the colors.

3 Likes

Awesome! thank you!

+20 characters

1 Like