判断列有没有显示, int k = 0; #region 得到已显示标题 for (int i = 0; i < gv.Columns.Count; i++) { if (gv.Columns[i].Visible == true) { for (int j = 0; j < gv.Columns.Count; j++) { if (gv.Columns[j].VisibleIndex == k) { ICell cell = row.CreateCell(k); cell.SetCellValue(gv.Columns[j].Caption.ToString()); if (gv.Columns[j].UnboundType.ToString() == "Decimal") { UnboundType[gv.Columns[j].FieldName] = "Decimal"; }//数字 else { UnboundType[gv.Columns[j].FieldName] = ""; }//字符 k++; } } } } #endregion