Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions OpenXmlFormats/Spreadsheet/Sheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2469,10 +2469,9 @@ public class CT_SheetFormatPr
private double dyDescentField;
public CT_SheetFormatPr()
{
this.baseColWidth = 8;
this.defaultColWidth = 8.43;
}
[XmlAttribute]
[DefaultValue(typeof(uint), "8")]
public uint baseColWidth
{
get
Expand All @@ -2486,6 +2485,7 @@ public uint baseColWidth
}

[XmlAttribute]
[DefaultValue(typeof(double), "8.43")]
public double defaultColWidth
{
get
Expand Down Expand Up @@ -2599,7 +2599,7 @@ public static CT_SheetFormatPr Parse(XmlNode node, XmlNamespaceManager namespace
if (node == null)
return null;
CT_SheetFormatPr ctObj = new CT_SheetFormatPr();
ctObj.baseColWidth = XmlHelper.ReadUInt(node.Attributes["baseColWidth"],8);
ctObj.baseColWidth = XmlHelper.ReadUInt(node.Attributes["baseColWidth"]);
ctObj.defaultColWidth = XmlHelper.ReadDouble(node.Attributes["defaultColWidth"]);
ctObj.defaultRowHeight = XmlHelper.ReadDouble(node.Attributes["defaultRowHeight"]);
ctObj.customHeight = XmlHelper.ReadBool(node.Attributes["customHeight"]);
Expand Down
8 changes: 4 additions & 4 deletions main/HSSF/Model/InternalSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ private static DefaultColWidthRecord CreateDefaultColWidth()
* @return default column width
*/

public int DefaultColumnWidth
public double DefaultColumnWidth
{
get { return defaultcolwidth.ColWidth; }
set { defaultcolwidth.ColWidth = (short)value; }
Expand Down Expand Up @@ -1292,7 +1292,7 @@ public short GetXFIndexForColAt(short columnIndex)
* @param column - the column number
* @param width (in Units of 1/256th of a Char width)
*/
public void SetColumnWidth(int column, int width)
public void SetColumnWidth(int column, double width)
{
if (width > 255 * 256)
throw new ArgumentException("The maximum column width for an individual cell is 255 characters.");
Expand Down Expand Up @@ -1332,12 +1332,12 @@ public void SetDefaultColumnStyle(int column, int styleIndex)
SetColumn(column, (short)styleIndex, null, null, null, null);
}

public void SetColumn(int column, int width, int level, bool hidden, bool collapsed)
public void SetColumn(int column, double width, int level, bool hidden, bool collapsed)
{
_columnInfos.SetColumn(column, 0, width, level, hidden, collapsed);
}

public void SetColumn(int column, short? xfStyle, int? width, int? level, bool? hidden, bool? collapsed)
public void SetColumn(int column, short? xfStyle, double? width, int? level, bool? hidden, bool? collapsed)
{
_columnInfos.SetColumn(column, xfStyle, width, level, hidden, collapsed);
}
Expand Down
4 changes: 2 additions & 2 deletions main/HSSF/Record/Aggregates/ColumnInfoRecordsAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public void ExpandColumn(int columnNumber)
/**
* Sets all non null fields into the <c>ci</c> parameter.
*/
private static void SetColumnInfoFields(ColumnInfoRecord ci, short? xfStyle, int? width,
private static void SetColumnInfoFields(ColumnInfoRecord ci, short? xfStyle, double? width,
int? level, Boolean? hidden, Boolean? collapsed)
{
if (xfStyle != null)
Expand Down Expand Up @@ -517,7 +517,7 @@ private int SetGroupHidden(int pIdx, int level, bool hidden)
/// <param name="level">The level.</param>
/// <param name="hidden">The hidden.</param>
/// <param name="collapsed">The collapsed.</param>
public void SetColumn(int targetColumnIx, short? xfIndex, int? width, int? level, bool? hidden, bool? collapsed)
public void SetColumn(int targetColumnIx, short? xfIndex, double? width, int? level, bool? hidden, bool? collapsed)
{
ColumnInfoRecord ci = null;
int k = 0;
Expand Down
14 changes: 7 additions & 7 deletions main/HSSF/UserModel/HSSFSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public bool IsColumnHidden(int column)
/// </summary>
/// <param name="column">the column to Set (0-based)</param>
/// <param name="width">the width in Units of 1/256th of a Char width</param>
public void SetColumnWidth(int column, int width)
public void SetColumnWidth(int column, double width)
{
_sheet.SetColumnWidth(column, width);
}
Expand All @@ -584,16 +584,16 @@ public void SetColumnWidth(int column, int width)
/// </summary>
/// <param name="column">the column to Set (0-based)</param>
/// <returns>the width in Units of 1/256th of a Char width</returns>
public int GetColumnWidth(int column)
public double GetColumnWidth(int column)
{
return _sheet.GetColumnWidth(column);
}

public float GetColumnWidthInPixels(int column)
public double GetColumnWidthInPixels(int column)
{
int cw = GetColumnWidth(column);
int def = DefaultColumnWidth * 256;
float px = (cw == def ? PX_DEFAULT : PX_MODIFIED);
double cw = GetColumnWidth(column);
double def = DefaultColumnWidth * 256;
double px = (cw == def ? PX_DEFAULT : PX_MODIFIED);

return cw / px;
}
Expand All @@ -602,7 +602,7 @@ public float GetColumnWidthInPixels(int column)
/// Gets or sets the default width of the column.
/// </summary>
/// <value>The default width of the column.</value>
public int DefaultColumnWidth
public double DefaultColumnWidth
{
get { return _sheet.DefaultColumnWidth; }
set { _sheet.DefaultColumnWidth = value; }
Expand Down
8 changes: 4 additions & 4 deletions main/SS/UserModel/Sheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ public interface ISheet
/// This value represents the number of characters that can be displayed
/// in a cell that is formatted with the standard font.
/// </remarks>
void SetColumnWidth(int columnIndex, int width);
void SetColumnWidth(int columnIndex, double width);

/// <summary>
/// get the width (in units of 1/256th of a character width )
/// </summary>
/// <param name="columnIndex">the column to get (0-based)</param>
/// <returns>the width in units of 1/256th of a character width</returns>
int GetColumnWidth(int columnIndex);
double GetColumnWidth(int columnIndex);

/// <summary>
/// get the width in pixel
Expand All @@ -189,14 +189,14 @@ public interface ISheet
/// with the default font size (Arial 10pt for .xls and Calibri 11pt for .xlsx).
/// If the default font is changed the column width can be streched
/// </remarks>
float GetColumnWidthInPixels(int columnIndex);
double GetColumnWidthInPixels(int columnIndex);

/// <summary>
/// Get the default column width for the sheet (if the columns do not define their own width)
/// in characters
/// </summary>
/// <value>default column width measured in characters.</value>
int DefaultColumnWidth { get; set; }
double DefaultColumnWidth { get; set; }

/// <summary>
/// Get the default row height for the sheet (if the rows do not define their own height) in
Expand Down
6 changes: 3 additions & 3 deletions ooxml/SS/Converter/ExcelToHtmlConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ExcelToHtmlConverter()
cssClassTable = htmlDocumentFacade.GetOrCreateCssClass("table", "t",
"border-collapse:collapse;border-spacing:0;");
}
protected static int GetColumnWidth(ISheet sheet, int columnIndex)
protected static double GetColumnWidth(ISheet sheet, int columnIndex)
{
return ExcelToHtmlUtils.GetColumnWidthInPx(sheet.GetColumnWidth(columnIndex));
}
Expand Down Expand Up @@ -295,7 +295,7 @@ protected int ProcessRow(CellRangeAddress[][] mergedRanges, IRow row,

ICell cell = (ICell)row.GetCell(colIx);

int divWidthPx = 0;
double divWidthPx = 0;
if (UseDivsToSpan)
{
divWidthPx = GetColumnWidth(sheet, colIx);
Expand Down Expand Up @@ -481,7 +481,7 @@ protected bool IsTextEmpty(ICell cell)
}

protected bool ProcessCell(ICell cell, XmlElement tableCellElement,
int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt)
double normalWidthPx, double maxSpannedWidthPx, float normalHeightPt)
{
ICellStyle cellStyle = cell.CellStyle as ICellStyle;

Expand Down
6 changes: 3 additions & 3 deletions ooxml/SS/Converter/ExcelToHtmlUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ public static string GetColor(HSSFColor color)
* "http://apache-poi.1045710.n5.nabble.com/Excel-Column-Width-Unit-Converter-pixels-excel-column-width-units-td2301481.html"
* >here</a> for Xio explanation and details
*/
public static int GetColumnWidthInPx(int widthUnits)
public static double GetColumnWidthInPx(double widthUnits)
{
int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR)
double pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR)
* UNIT_OFFSET_LENGTH;

int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR;
double offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR;
pixels += (int)Math.Round(offsetWidthUnits / ((float)EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH));

return pixels;
Expand Down
8 changes: 4 additions & 4 deletions ooxml/XSSF/Streaming/SXSSFSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public int[] ColumnBreaks
//set { _sh.ColumnBreaks = value; }
}

public int DefaultColumnWidth
public double DefaultColumnWidth
{
get
{
Expand Down Expand Up @@ -768,12 +768,12 @@ public ICellStyle GetColumnStyle(int column)
return _sh.GetColumnStyle(column);
}

public int GetColumnWidth(int columnIndex)
public double GetColumnWidth(int columnIndex)
{
return _sh.GetColumnWidth(columnIndex);
}

public float GetColumnWidthInPixels(int columnIndex)
public double GetColumnWidthInPixels(int columnIndex)
{
return _sh.GetColumnWidthInPixels(columnIndex);
}
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public void SetColumnHidden(int columnIndex, bool hidden)
_sh.SetColumnHidden(columnIndex, hidden);
}

public void SetColumnWidth(int columnIndex, int width)
public void SetColumnWidth(int columnIndex, double width)
{
_sh.SetColumnWidth(columnIndex, width);
}
Expand Down
6 changes: 3 additions & 3 deletions ooxml/XSSF/UserModel/XSSFDialogsheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ bool ISheet.IsColumnHidden(int columnIndex)
throw new System.NotImplementedException();
}

void ISheet.SetColumnWidth(int columnIndex, int width)
void ISheet.SetColumnWidth(int columnIndex, double width)
{
throw new System.NotImplementedException();
}

int ISheet.GetColumnWidth(int columnIndex)
double ISheet.GetColumnWidth(int columnIndex)
{
throw new System.NotImplementedException();
}

int ISheet.DefaultColumnWidth
double ISheet.DefaultColumnWidth
{
get
{
Expand Down
Loading