Example #1
0
 internal Column(ColumnRange columnRange, int index)
     : this(columnRange.Worksheet, index, columnRange.StyleIndex, columnRange.Width, columnRange.IsBestFit, columnRange.IsCustomWidth)
 {
     if (index < columnRange.MinIndex || index > columnRange.MaxIndex)
         throw new ArgumentOutOfRangeException();
 }
Example #2
0
        // Write
        internal static void WriteColumnRangeToWriter(CustomOpenXmlWriter<OpenXmlPackaging.WorksheetPart> writer, ColumnRange columnRange)
        {
            writer.WriteOpenXmlElement(new OpenXmlSpreadsheet.Column());

            writer.WriteAttribute("min", columnRange.MinIndex);
            writer.WriteAttribute("max", columnRange.MaxIndex);
            if (columnRange.StyleIndex > 0) writer.WriteAttribute("style", columnRange.StyleIndex);
            writer.WriteAttribute("width", columnRange.Width);
            if (columnRange.IsBestFit) writer.WriteAttribute("bestFit", columnRange.IsBestFit);
            if (columnRange.IsCustomWidth) writer.WriteAttribute("customWidth", columnRange.IsCustomWidth);

            writer.WriteEndElement();   // Column
        }
Example #3
0
 /***********************************
  * PUBLIC METHODS
  ************************************/
 /// <summary>
 /// Creates a copy of the ColumnRange and assigns to the given Worksheet.
 /// </summary>
 public ColumnRange Clone(Worksheet worksheet)
 {
     ColumnRange newColumnRange = new ColumnRange(worksheet, MinIndex, MaxIndex, StyleIndex, Width, IsBestFit, IsCustomWidth);
     return newColumnRange;
 }
Example #4
0
        /***********************************
         * PRIVATE METHODS
         ************************************/
        /***********************************
         * DAL METHODS
         ************************************/
        // Read
        internal static ColumnRange ReadColumnRangeFromReader(CustomOpenXmlReader reader, Worksheet worksheet)
        {
            int min = 0;
            int max = 0;
            int styleIndex = CellFormat.DefaultStyleIndex;
            double width = -1;
            bool isBestFit = false;
            bool isCustomWidth = false;

            foreach (CustomOpenXmlAttribute attribute in reader.Attributes)
            {
                switch (attribute.LocalName)
                {
                    case "min":
                        min = attribute.GetIntValue();
                        break;
                    case "max":
                        max = attribute.GetIntValue();
                        break;
                    case "style":
                        styleIndex = attribute.GetIntValue();
                        break;
                    case "width":
                        width = attribute.GetDoubleValue();
                        break;
                    case "bestFit":
                        isBestFit = attribute.GetBoolValue();
                        break;
                    case "customWidth":
                        isCustomWidth = attribute.GetBoolValue();
                        break;
                }
            }

            ColumnRange columnRange = new ColumnRange(worksheet, min, max, styleIndex, width, isBestFit, isCustomWidth);
            return columnRange;
        }