Code Monkey home page Code Monkey logo

Comments (5)

freb avatar freb commented on July 25, 2024

Appologies, I just stumbled onto the SetColumnSpan method on cell.Properties(): https://github.com/baliance/gooxml/blob/master/document/cellproperties.go#L28

So looks like merging cells is already implemented. I'll leave this open for feedback on table styles.

from unioffice.

tbaliance avatar tbaliance commented on July 25, 2024

@freb You may want to check out baliance.com/gooxml/_examples/document/tables if you haven't already, it has an example of SetColumnSpan. I'll update the document to mention the phrase 'merged cells' to help in future users that search for it.

Adding support for table styles is pretty trivial from the table side, it's just allowing setting the style and some attributes on the 'look'. (Though that val in tblLook is apparently a 'Bitmask of Table Conditional Formatting', that I'd need to research). I can probably knock that out in the next day or so.

<w:tblStyle w:val="PlainTable1"/>
<w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>

It would take a bit longer to finish fleshing out the styles with support for table to allow you to create something like this:

    <w:style w:type="table" w:styleId="PlainTable1">
        <w:name w:val="Plain Table 1"/><w:basedOn w:val="TableNormal"/>
        <w:uiPriority w:val="41"/>
        <w:rsid w:val="00811EB9"/>
        <w:tblPr>
            <w:tblStyleRowBandSize w:val="1"/>
            <w:tblStyleColBandSize w:val="1"/>
            <w:tblInd w:w="0" w:type="dxa"/>
            <w:tblBorders>
                <w:top w:val="single" w:sz="4" w:space="0" w:color="BFBFBF" w:th
emeColor="background1" w:themeShade="BF"/><w:left w:val="single" w:sz="4" w:spac
e="0" w:color="BFBFBF" w:themeColor="background1" w:themeShade="BF"/>
                <w:bottom w:val="single" w:sz="4" w:space="0" w:color="BFBFBF" w
:themeColor="background1" w:themeShade="BF"/>
                <w:right w:val="single" w:sz="4" w:space="0" w:color="BFBFBF" w:
themeColor="background1" w:themeShade="BF"/>
                <w:insideH w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"
w:themeColor="background1" w:themeShade="BF"/>
                <w:insideV w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"
w:themeColor="background1" w:themeShade="BF"/>
            </w:tblBorders>
            <w:tblCellMar>
                <w:top w:w="0" w:type="dxa"/>
                <w:left w:w="108" w:type="dxa"/>
                <w:bottom w:w="0" w:type="dxa"/>
                <w:right w:w="108" w:type="dxa"/>
            </w:tblCellMar>
        </w:tblPr>
        <w:tblStylePr w:type="firstRow">
            <w:rPr>
                <w:b/><w:bCs/>
            </w:rPr>
        </w:tblStylePr>
        <w:tblStylePr w:type="lastRow">
            <w:rPr>
                <w:b/><w:bCs/>
            </w:rPr>
            <w:tblPr/>
            <w:tcPr>
                <w:tcBorders>
                    <w:top w:val="double" w:sz="4" w:space="0" w:color="BFBFBF" w:themeColor="background1" w:themeShade="BF"/>
                </w:tcBorders>
            </w:tcPr>
        </w:tblStylePr>
        <w:tblStylePr w:type="firstCol">
            <w:rPr>
                <w:b/><w:bCs/>
            </w:rPr>
        </w:tblStylePr>
        <w:tblStylePr w:type="lastCol">
            <w:rPr>
                <w:b/><w:bCs/>
            </w:rPr>
        </w:tblStylePr>
        <w:tblStylePr w:type="band1Vert">
            <w:tblPr/>
            <w:tcPr>
                <w:shd w:val="clear" w:color="auto" w:fill="F2F2F2" w:themeFill="background1" w:themeFillShade="F2"/>
            </w:tcPr>
        </w:tblStylePr>
        <w:tblStylePr w:type="band1Horz">
            <w:tblPr/>
            <w:tcPr>
                <w:shd w:val="clear" w:color="auto" w:fill="F2F2F2" w:themeFill="background1" w:themeFillShade="F2"/>
            </w:tcPr>
        </w:tblStylePr>
    </w:style>

from unioffice.

freb avatar freb commented on July 25, 2024

Sorry about the SetColumnSpan, I found that a short while after posting.

For my use case, I don't have much interest in being able to generate a table style from scratch. I'll always be working off of at least a dotx file where it would be a lot easier to generate the style in Word for use with gooxml. Being able to easily set the style on the table would be nice though.

from unioffice.

tbaliance avatar tbaliance commented on July 25, 2024

@freb Using predefined styles is in master now, see document/use-template for an example. I created #131 to track creating table styles from scratch.

from unioffice.

freb avatar freb commented on July 25, 2024

This looks awesome. I'll let you know if I run into any issues. Thanks!

from unioffice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.