Browse Source

fix CopyRow bugs:

1.修复目标位置有row时不创建新行的bug。
2.修复移动行行高被重置的bug。
3.修复新行没有复制原行高度的bug。
master
Jie 7 years ago
parent
commit
cc39ca7c68
  1. 16
      src/NPOI/SS/Util/SheetUtil.cs

16
src/NPOI/SS/Util/SheetUtil.cs

@ -170,7 +170,7 @@ namespace NPOI.SS.Util
targetSheet.AddMergedRegion(newCellRangeAddress);
}
}
return newRow;
return newRow;
}
public static IRow CopyRow(ISheet sheet, int sourceRowIndex, int targetRowIndex)
{
@ -183,12 +183,12 @@ namespace NPOI.SS.Util
// If the row exist in destination, push down all rows by 1 else create a new row
if (newRow != null)
{
sheet.ShiftRows(targetRowIndex, sheet.LastRowNum, 1);
}
else
{
newRow = sheet.CreateRow(targetRowIndex);
sheet.ShiftRows(targetRowIndex, sheet.LastRowNum, 1, true, false);
}
//new row
newRow = sheet.CreateRow(targetRowIndex);
//copyHeight
newRow.Height = sourceRow.Height;
// Loop through source columns to add to new row
for (int i = sourceRow.FirstCellNum; i < sourceRow.LastCellNum; i++)
@ -312,7 +312,7 @@ namespace NPOI.SS.Util
//TextLayout layout;
double width = -1;
using (Bitmap bmp = new Bitmap(1,1))
using (Bitmap bmp = new Bitmap(1, 1))
using (Graphics g = Graphics.FromImage(bmp))
{
if (cellType == CellType.String)
@ -450,7 +450,7 @@ namespace NPOI.SS.Util
IWorkbook wb = sheet.Workbook;
DataFormatter formatter = new DataFormatter();
IFont defaultFont = wb.GetFontAt((short) 0);
IFont defaultFont = wb.GetFontAt((short)0);
//str = new AttributedString((defaultChar));
//copyAttributes(defaultFont, str, 0, 1);

Loading…
Cancel
Save