Write support in github.com/tealeg/xlsx

905 views
Skip to first unread message

Geoffrey Teale

unread,
Sep 13, 2014, 6:28:03 PM9/13/14
to golang-nuts
Evenin' all,

I'll de-lurk for just a few moments to mention that my XLSX library has grown the ability to write very trivial XLSX files as well as reading them.  More advanced facilities will follow at some point in the future.  If any of this sounds like something you'd be interested in you can check it out at:


Trivial examples of how to use it are contained in the xlsx2csv and csv2xlsx projects:


That's right folks, Go can do boring things too!.  
-- 
Geoff Teale
Mundane in the membrane / Mundane in the brain!

John Jeffery

unread,
Sep 14, 2014, 5:55:27 AM9/14/14
to golan...@googlegroups.com
Thanks Geoff. This is of interest to me, I'll check it out.

Sil

unread,
Oct 7, 2014, 11:27:45 PM10/7/14
to golan...@googlegroups.com
Hi Geoff,

Great package, and many thanks for this. I'm fairly new to Go, but I wrote a small xml to xlsx package using your library, which is really useful. 

I was wondering if you:

1) happen to know why Excel 2013 is prone to give this warning: "We found a problem with some content in [generated file name.xlsx. Do you want us to try to recover as much as we can ?"
But nothing appears to be broken - the generated data had made its way into the file. So that's strange.

2) could give an example how to apply bold style to fonts.

The following snippet I attempted is not doing the trick (I tried Arial Black just because but the question would be more generic how to apply the "font-weight" as bold to any kind of font)

                    log.Printf("Setting Arial Black for this cell as I have no idea how to set font-weight")
                    cell = row.AddCell()                
                    font := xlsx.NewFont(11, "Arial Black")
                    style := xlsx.NewStyle()
                    style.Font = *font                    
                    cell.SetStyle(style)  
                    cell.Value = "abc"

Many thanks and regards,
Silviu

Geoffrey Teale

unread,
Oct 8, 2014, 9:16:54 AM10/8/14
to Sil, golang-nuts
Hi Silviu,

I don't know why you're getting that message from Excel 2013.  I don't have Microsoft Office around to test with (Indeed, I only test on Linux).   If you'd like to raise a bug against the project, and provide a sample document that's generating that message, we can perhaps work together to identify the problem.

With regards to how you set bold font.   The intent is close to what you've provided, but curretly we don't write style information out, so setting fonts won't have any effect.  I do plan to deliver that functionality, but I'm not working on this currently.

--
Geoff

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Silviu Capota Mera

unread,
Oct 8, 2014, 9:35:04 AM10/8/14
to Geoffrey Teale, golang-nuts
Hi Geoff,

Thanks for your reply !

Attached a zip file with the .go file and the generated .xslx file that is being deemed as broken in Excel 2013.
The sample xml is at the top in a constant, and I loop through that to generate the Excel file - the main method of the file is GenerateExcel

Please let me know if on your machine (Linux) that xlsx is deemed as perfectly valid.
(again, the data is written intact inside, it's just the initial tendency of Excel to report it as semi-broken and offer to repair it)

Regards
Silviu


xmlToExcel.zip

Geoffrey Teale

unread,
Oct 13, 2014, 2:13:16 PM10/13/14
to Silviu Capota Mera, golang-nuts
For those who are interested, this issue is now tracked on the github project page for XLSX:


Regards,
Geoff Teale.
Reply all
Reply to author
Forward
0 new messages