您好,
经过调查,这个问题是在客户的项目通过代码处置的字体??发生。
private void ChangeFont(string fontName, float size, FontStyle style, bool toogled, bool isToogle)
{
try
{
SheetView sheet = this.fpSpread1.ActiveSheet;
CellRange[] cellRanges = GetSpreadSelections();
foreach (CellRange cellRange in cellRanges)
{
for (int i = 0; i < cellRange.RowCount; i++)
{
for (int j = 0; j < cellRange.ColumnCount; j++)
{
Font cellFont = sheet.GetStyleInfo(i + cellRange.Row, j + cellRange.Column).Font ?? fpSpread1.Font;
bool hasCellFont = sheet.Cells[i + cellRange.Row, j + cellRange.Column].Font != null;
sheet.Cells[i + cellRange.Row, j + cellRange.Column].Font = new Font(string.IsNullOrEmpty(fontName) ? cellFont.Name : fontName
, size > 0 ? size : cellFont.Size
, isToogle ? toogled ? cellFont.Style | style : cellFont.Style & ~style : style
, cellFont.Unit);
if (hasCellFont)
cellFont.Dispose(); //=> Dispose the font is using.
}
}
}
}
catch (System.Exception ex)
{
MessageBox.Show("ChangeFont" + ex.Message);
}
}
解决方案:注释以下代码
//if (hasCellFont)
// cellFont.Dispose(); //=> Dispose the font is using. |