public void TestCreateAndLoad()
 {
     CommonNamespaces cs = new CommonNamespaces(OpenXmlFormat.Transitional);
     XlsxPredefinedTableXmlFilter filter = new XlsxPredefinedTableXmlFilter("TableStyleMedium28", cs);
     Assert.IsTrue(filter.TargetTableStyle == "TableStyleMedium28", "didn't set the table style target");
     filter.Read();
 }
Exemple #2
0
        //the order they are applied is based on the Pt4 - language reference documentation
        private void ApplyEachStyleInTurn(PredefinedTableData ptd, ref CellFormatData cfd)
        {
            if (m_currentTableStyle != ptd.StyleName)
            {
                m_currentTableStyle = ptd.StyleName;
                m_currentTableFilter = new XlsxPredefinedTableXmlFilter(m_currentTableStyle, m_commonNamespaces);
                m_currentTableFilter.Read();
            }

            if (m_currentTableFilter != null && m_currentTableFilter.TableStyleElements!=null && m_currentTableFilter.TableStyleElements.Count > 0)
            {
                if (m_currentTableFilter.TableStyleElements.ContainsKey("wholeTable"))
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["wholeTable"], ref cfd);
                }

                if ((ptd.CurrentCellStyle & TableCellStyle.firstColumnStripe) != 0)
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["firstColumnStripe"], ref cfd);
                }
                if ((ptd.CurrentCellStyle & TableCellStyle.firstRowStripe) != 0)
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["firstRowStripe"], ref cfd);
                }
                if ((ptd.CurrentCellStyle & TableCellStyle.lastColumn) != 0)
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["lastColumn"], ref cfd);
                }
                if ((ptd.CurrentCellStyle & TableCellStyle.firstColumn) != 0)
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["firstColumn"], ref cfd);
                }
                if ((ptd.CurrentCellStyle & TableCellStyle.headerRow) != 0)
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["headerRow"], ref cfd);
                }
                if ((ptd.CurrentCellStyle & TableCellStyle.totalRow) != 0)
                {
                    ApplyStyle(m_currentTableFilter.TableStyleElements["totalRow"], ref cfd);
                }
                if (ptd.CurrentCellStyle == TableCellStyle.wholeTable)
                {//if it is only whole table it uses the fill.background, so reset the foreground to this to simplify comparison
                    ApplyWholeTableBackground(ref cfd);
                }
            }
        }