public void AddToTableData(PredefinedTableData tableData)
 {
     Dictionary<string, PredefinedTableData> actualTableData;
     if (m_tableData.TryGetValue(tableData.ParentSheet, out actualTableData))
     {
         if (!actualTableData.ContainsKey(tableData.rId))
             actualTableData.Add(tableData.rId, tableData);
     }
     else
     {
         actualTableData = new Dictionary<string, PredefinedTableData>(); 
         actualTableData.Add(tableData.rId, tableData);
         m_tableData.Add(tableData.ParentSheet, actualTableData);
     }
 }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 3
0
        private void ResolveCurrentCellStyle(string cellRef, PredefinedTableData ptd)
        {
            CellFormatData cfd = new CellFormatData();

            ApplyEachStyleInTurn(ptd, ref cfd);
            ApplyCurrentCellStyleOverride(ref cfd);
            ResolveStateBasedOnCellFormatData(cfd);
        }
Exemplo n.º 4
0
        private bool IsInTable(string cellRef, out PredefinedTableData ptd)
        {
            foreach (KeyValuePair<string, PredefinedTableData> kvp in m_currentTableData)
            {
                ptd = kvp.Value;

                if (ptd.ResolveCurrentCellState(cellRef))
                {
                    m_inTable = true;
                    return true;
                }
            }
            ptd = null;
            return false;
        }
Exemplo n.º 5
0
        private bool ShouldResolveCellStateBasedOnTableStyle(XmlNodeInformation nodeInfo, XlsxProcessingDictionaries processingDictionaries, out PredefinedTableData ptd)
        {
            string cellRef = nodeInfo.GetAttributeValue("r");

            if (!string.IsNullOrEmpty(cellRef))
            {

                if (m_targetHasChanged)
                {
                    if (processingDictionaries.GetActualTableData(m_currentTarget, out m_currentTableData))
                    {
                        foreach (KeyValuePair<string, PredefinedTableData> kvp in m_currentTableData)
                        {
                            ptd = kvp.Value;

                            if (ptd.ResolveCurrentCellState(cellRef))
                            {
                                m_inTable = true;
                                return true;
                            }
                        }
                    }
                }
                else
                {
                    if (m_currentTableData != null)
                    {
                        return IsInTable(cellRef, out ptd);
                    }
                }
            }

            ptd = null;
            return false;
          }