Aspose.Cells相应操作
1,上传
1.1 Workbook
Workbook workBook = new Workbook(); | ||||
属性: | ||||
| 名称 | 值类型 | 说明 | |
| Colors | Color[] | 获取或设置Excel颜色 | |
| ConvertNumericData | bool | 获取或设置是否将字符串转换至数字数据 默认值为 true | |
| DataSorter | DataSorter | 获取或设置数据分级 | |
| Date1904 | bool |
| |
| DefaultStyle | Aspose.Cells.Style | 获取或设置工作簿默认样式 | |
| HasMacro | bool | 获取工作簿是否包含宏观调控或宏 | |
| IsHScrollBarVisible | bool | 获取或设置左部滚动条(控制行) 默认值为true | |
| IsProtected | bool | 获取工作簿保护状态 | |
| IsVScrollBarVisible | bool | 获取或设置底部滚动条(控制列) 默认值为true | |
| Language | CountryCode --枚举类型 | 获取或设置语言 默认为当前计算机区域 | |
| Password | string | 获取或设置工作簿密码 | |
| ReCalcOnOpen | bool | 获取或设置是否重新计算所有打开文件的公式 | |
| Region | CountryCode --枚举类型 | 获取或设置工作簿区域(指当前使用者区域) 默认为当前计算机区域 | |
| Shared | bool | 获取或设置当前工作簿是否共享 默认为false | |
| ShowTabs | bool | 获取或设置是否显示标签(工作表标签) 默认为true | |
| Styles | Styles | 样式集合 | |
| Worksheets | Worksheet |
| |
事件: | ||||
| CalculateFormula(bool ignoreError ,ICustomFunction customFunction) +3 | void | 计算公式 | |
| ChangePalette(Color color,int index) | void | 设置当前颜色在调色版中显示顺序 | |
| Combine(Workbook secondWorkbook) | void | 联合工作簿,将secondWorkbook 工作簿中workSheet追加到当前工作簿中 | |
| Copy(Workbook source) | void | 拷贝工作簿到当前工作簿 | |
| Decrypt(string password) | void | 解除工作簿密码 | |
| IsColorInPalette(Color color) | bool | 将color加入到当前Excel调色版 | |
| LoadData(string fileName) LoadData(System.IO.Stream stream) | void | 加载Excel到当前Workbook中 | |
| Open(string fileName, FileFormatType.Default, string password ); +8 | void | 打开Excel文件 | |
| Protect(ProtectionType.All, string password); | void | 写保护,并设置取消工作簿保护密码 | |
| RemoveExternalLinks() | void | 移除外部链接 | |
| RemoveMacro() | void | 移除宏 | |
| Replace (string PlaceHolder, string newValue); +8 | void | 工作簿中类型和值完全符合的单元格,将其替换为新值或对象 | |
| Save(Server.UrlEncode("测试.xls"), FileFormatType.Default, SaveType.OpenInExcel, Response);+8 | Void | 保存工作簿 | |
| SaveToStream() | System.IO.MemoryStream | 将工作簿写入内存流中 | |
| Unprotect(string password); | Void | 取消工作簿保护状态 | |
| ValidateFormula(string formula) | bool | 验证公式 |
1.2 Worksheet
Worksheet worksheet=workbook.Worksheets[index]; or Worksheet worksheet= new Worksheet(); | |||
属性: | |||
| 名称 | 值类型 | 说明 |
| ActiveCell | string | 获取或设置当前活动单元格 |
| AutoFilter | AutoFilter | 自动筛选 |
| Cells | Cells | 单元格集合 |
| Charts | Charts |
|
| CheckBoxes | CheckBoxes |
|
| CodeName | string | 获取编码名称(“Sheet1”。。。) |
| Comments | Comments |
|
| ConditionalFormattings | ConditionalFormattings |
|
| DisplayRightToLeft | bool | 获取或设置当前工作表显示方向;是否从右至左 默认为 false |
| FirstVisibleColumn | int | 获取或设置当前工作表显示的起始行 |
| FirstVisibleRow | int | 获取或设置 工作表显示的起始列 |
| HPageBreaks | HPageBreaks |
|
| Hyperlinks | Hyperlinks |
|
| Index | int | 获取当前工作表索引(标签位置); 下标从0开始 |
| IsGridlinesVisible | bool | 获取或设置是否显示网格 |
| IsPageBreakPreview | bool | 获取或设置是否显示为分页预览 默认为false |
| IsProtected | bool | 获取Excel保护状态 |
| IsRowColumnHeadersVisible | bool | 获取或设置是否显示行和列标题;默认为true |
| IsVisible | bool | 获取或设置是否显示当前标签; 默认为 true |
| ListObjects | ListObjects |
|
| Name | string | 获取或设置标签名称 |
| OleObjects | OleObjects |
|
| Outline | Outline |
|
| PageSetup | PageSetup |
|
| Pictures | Pictures |
|
| PivotTables | PivotTables |
|
| Protection | Protection |
|
| Shapes | Shapes |
|
| TabColor | System.Drawing.Color | 获取或设置标签颜色 |
| TextBoxes | TextBoxes |
|
| Type | SheetType—枚举值 |
|
| Validations | Validations |
|
| VPageBreaks | VPageBreaks |
|
| Workbook | Workbook | 当前标签的Workbook |
| Zoom | int | 获取或设置显示比例;单位为百分比,有效数值10-400之间 |
1.2.1 AutoFitColumn
指定列设置为自适应列宽 void Worksheet.AutoFitColumn(columnIndex,firstRow,lastRow); +2 | |||
| 名称 | 值类型 | 说明 |
| columnIndex | int | 列标,从0开始 |
| firstRow | int | 开始行,从0开始 |
| lastRow | int | 结束行,从0开始 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.2 AutoFitColumns
设置所有列为自适应列宽 void Worksheet.AutoFitColumns(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.3 AutoFitRow
指定行设置为自适应行宽 void Worksheet. AutoFitRow(rowIndex,firstColumn,lastColumn); +2 | |||
| 名称 | 值类型 | 说明 |
| rowIndex | int | 行标,从0开始 |
| firstColumn | int | 开始列,从0开始 |
| lastColumn | int | 结束列,从0开始 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.3 ClearComments
清除所有批注 void Worksheet.ClearComments(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.4 Copy
清除所有批注 void Worksheet.Copy(sourcesheet); | |||
| 名称 | 值类型 | 说明 |
| sourcesheet | Workbook | 工作表源 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.5 CopyConditionalFormatting
拷贝有条件的格式 void Worksheet.CopyConditionalFormatting(sourceRow,sourceColumn,destRow,destColumn); | |||
| 名称 | 值类型 | 说明 |
| sourceRow | int | 源行标 |
| sourceColumn | int | 源列标 |
| destRow | int | 目的地行标 |
| destColumn | int | 目的地列标 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.6 CopyConditionalFormatting
冻结窗格 void Worksheet.FreezePanes(cellName,freezedRows,freezedColumns) or (Row,Column,freezedRows,freezedColumns); +2 | |||
| 名称 | 值类型 | 说明 |
| cellName | string | 单元格名称;例:B2 |
| freezedRows | int | 冻结行(项标显示行数,如果行数大于freezedRows,超出行隐藏) |
| freezedColumns | int | 冻结列(左标显示列数,如果列数大于freezedColumns,超出列隐藏) |
| Row | int | 行标 |
| Column | int | 列标 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.7 GetSelectedRanges
获取当前光标停留的单元格 ArrayList Worksheet.GetSelectedRanges() | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| System.Collections.ArrayList |
|
1.2.8 Move
获取当前光标停留的单元格 void Worksheet.Move(index) | |||
| 名称 | 值类型 | 说明 |
| index | int | 移动至索引序号 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.9 Protect
写保护 void Worksheet.Protect(type,password,oldPassword); +2 | |||
| 名称 | 值类型 | 说明 |
| type | ProtectionType –枚举型 | 设置保护 |
| password | string |
|
| oldPassword | string |
|
| |||
| 返回 | 说明 | |
| void |
|
1.2.10 RemoveAllDrawingObjects
删除所有图画(图表)对象 void Worksheet.RemoveAllDrawingObjects(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.11 RemoveSplit
删除拆分 void Worksheet.RemoveSplit(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.12 Replace
在工作表中替换符合要求单元格值 void Worksheet.Replace(oldString, newString); | |||
| 名称 | 值类型 | 说明 |
| oldString | string | 要替换字符串(完全相等) |
| newString | string | 替换字符串 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.13 SetBackground
设置背景图片 void Worksheet.SetBackground(pictureData); | |||
| 名称 | 值类型 | 说明 |
| pictureData | byte[] | 图片字节 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.14 Split
拆分工作表 void Worksheet.Split(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.15 UnFreezePanes
联合冻结窗格 void Worksheet.UnFreezePanes(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.2.16 Unprotect
解除保护 void Worksheet.Unprotect(password); | |||
| 名称 | 值类型 | 说明 |
| password | string | 工作表密码 |
| |||
| 返回 | 说明 | |
| void |
|
1.3 Worksheets
Worksheets worksheets= workbook.Worksheets; or Worksheets worksheets= new Worksheets(); | |||
属性: | |||
| 名称 | 值类型 | 说明 |
| ActiveSheetIndex | int | 获取或设置当前活动工作表 |
| BuiltInDocumentProperties | BuiltInDocumentProperties | 设置内置文件属性 |
| Capacity | int | 获取或设置工作表包含元素数 |
| Count | int | 获取工作表数量 |
| CustomDocumentProperties | CustomDocumentProperties | 承接定做活的文件属性 |
| EnableHTTPCompression | bool | 获取或设置使用HTTP压缩 |
| ExternalLinks | ExternalLinks | 获取或设置外部链接 |
| Names | Names |
|
| SheetTabBarWidth | int | 获取或设置工作表标签列表显示宽度;有效宽度1/1000 |
| WindowHeightCM | double |
|
| WindowHeightInch | double |
|
| WindowLeftCM | double |
|
| WindowLeftInch | double |
|
| WindowTopCM | double |
|
| WindowTopInch | double |
|
| WindowWidthCM | double |
|
| WindowWidthInch | double |
|
1.3.1 Add +3
新增工作表 Worksheet Worksheets.Add(); or Worksheet Worksheets.Add(type) or Worksheet Worksheets.Add(sheetName) | |||
| 名称 | 值类型 | 说明 |
| type | SheetType –枚举型 | 新增工作表的类型 |
| sheetName | string | 新增工作表标签名 |
| |||
| 返回 | 说明 | |
| Worksheet |
|
1.3.2 AddCopy +2
拷贝现有工作表至新增工作表 int Worksheets.AddCopy(sheetIndex); or int Worksheets.AddCopy(sheetName); | |||
| 名称 | 值类型 | 说明 |
| sheetIndex | int | 工作表的索引 |
| sheetName | string | 工作表标签名 |
| |||
| 返回 | 说明 | |
| int |
|
1.3.3 Clear
删除当前工作表 void Worksheets.Clear(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.3.4 DeleteName
删除指定的 range void Worksheets.DeleteName(definedName); | |||
| 名称 | 值类型 | 说明 |
| definedName | string | range的名称 |
| |||
| 返回 | 说明 | |
| void |
|
1.3.5 GetEnumerator
获取所有统计员 IEnumerator Worksheets.GetEnumerator(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| IEnumerator | 统计员接口 |
1.3.6 GetNamedRanges
获取所有range实体 Range[] Worksheets.GetNamedRanges(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| Range[] | range实体 |
1.3.7 GetRangeByName
根据 range来获取 Range Worksheets. GetRangeByName(rangeName); | |||
| 名称 | 值类型 | 说明 |
| rangeName | string | range名称 |
| |||
| 返回 | 说明 | |
| Range |
|
1.3.8 RemoveAt
删除工作表 void Worksheets.RemoveAt(indexer); Or void Worksheets.RemoveAt(name); | |||
| 名称 | 值类型 | 说明 |
| indexer | int | 工作表索引 |
| name | string | 工作表名称 |
| |||
| 返回 | 说明 | |
| void |
|
1.3.9 SetOleSize
Sets displayed size when Workbook file is used as an Ole object. void Worksheets.SetOleSize(startRow,endRow,startColumn,endColumn); | |||
| 名称 | 值类型 | 说明 |
| startRow | int | 起始行 |
| endRow | int | 结束行 |
| startColumn | int | 起始列 |
| endColumn | int | 结束列 |
| |||
| 返回 | 说明 | |
| void |
|
1.3.10 SortNames
按名称排序range void Worksheets.SortNames(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.4 Cells
Cells cells = new Cells(); or Worksheets.Cells | |||
属性: | |||
| 名称 | 值类型 | 说明 |
| Capacity | int | 获取或设置包含元素数 |
| Columns | Columns | 列集合 |
| Count | int | 获取有效单元格数量(非空单元格) |
| End | Cell | 获取最后单元格 |
| IsStringsPreserved | bool | 获取或设置是否用字符来代替密码 |
| MaxColumn | int | 获取当前工作表最大列,列下标从0开始 |
| MaxDataColumn | int | 获取最大包含数据列;列下标从0开始 |
| MaxDataRow | int | 获取最大包含数据行; 行下标从0开始 |
| MaxRow | int | 获取最大行,行下标从0开始 |
| MergedCells | System.Collections.ArrayList | 合并单元格 |
| MinColumn | int | 获取最小列, 列下标从0开始 |
| MinRow | int | 获取最小行,行下标从0开始 |
| Ranges | Ranges | 获取或设置range实体类 |
| Rows | Rows | 行集合 |
| StandardHeight | double | 获取或设置单元格高度 |
| StandardWidth | double | 获取或设置单元格宽度 |
| Start | Cell | 起始单元格 |
1.4.1 ApplyColumnStyle
设置工作表列样式 void Cells.ApplyColumnStyle(Column,style,styleFlag); | |||
| 名称 | 值类型 | 说明 |
| Column | int | 列号,下标从0开始 |
| style | Style |
|
| styleFlag | StyleFlag |
|
| |||
| 返回 | 说明 | |
| void |
|
1.4.2 ApplyRowStyle
设置工作表行样式 void Cells.ApplyRowStyle(row,style,styleFlag); | |||
| 名称 | 值类型 | 说明 |
| row | int | 行号,下标从0开始 |
| style | Style |
|
| styleFlag | StyleFlag |
|
| |||
| 返回 | 说明 | |
| void |
|
1.4.3 ApplyStyle
设置工作表所有单元格样式 void Cells.ApplyStyle(style,styleFlag); | |||
| 名称 | 值类型 | 说明 |
| style | Style |
|
| styleFlag | StyleFlag |
|
| |||
| 返回 | 说明 | |
| void |
|
1.4.4 CheckExistence
检查单元格,如果为空返回-1,否刚返回从0行0列单元格开始至当前检索单元格非空值数量 int Cells.CheckExistence(row,column); | |||
| 名称 | 值类型 | 说明 |
| row | int |
|
| column | int |
|
| |||
| 返回 | 说明 | |
| int | 如果为空返回-1,否刚返回从0行0列单元格开始至当前检索单元格非空值数量 |
1.4.5 Clear
删除所有单元格数据 void Cells.Clear(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.6 ClearContents
删除起始单元格至结束单元格数据 void Cells.ClearContents(startRow,startColumn,endRow,endColumn); | |||
| 名称 | 值类型 | 说明 |
| startRow | int | 起始行 |
| startColumn | int | 起始列 |
| endRow | int | 结束行 |
| endColumn | int | 结束列 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.7 ClearFormats
删除起始单元格至结束单元格格式 void Cells.ClearFormats(startRow,startColumn,endRow,endColumn); | |||
| 名称 | 值类型 | 说明 |
| startRow | int | 起始行 |
| startColumn | int | 起始列 |
| endRow | int | 结束行 |
| endColumn | int | 结束列 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.8 ClearRange
删除起始单元格至结束单元格格式和数据 void Cells.ClearRange(startRow,startColumn,endRow,endColumn); | |||
| 名称 | 值类型 | 说明 |
| startRow | int | 起始行 |
| startColumn | int | 起始列 |
| endRow | int | 结束行 |
| endColumn | int | 结束列 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.9 ConvertStringToNumericValue
将所有字符串型数据转换为数值型数据 void Cells.ConvertStringToNumericValue(); | |||
| 名称 | 值类型 | 说明 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.10 CopyColumn
拷贝列 void Cells.CopyColumn(sourceCells,sourceColumnIndex,destinationColumnIndex); | |||
| 名称 | 值类型 | 说明 |
| sourceCells | Cells | 源单元格集合 |
| sourceColumnIndex | int | 源列索引 |
| destinationColumnIndex | int | 目的地列索引 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.11 CopyRow
拷贝行 void Cells.CopyRow(sourceCells, sourceRowIndex, destinationRowIndex); | |||
| 名称 | 值类型 | 说明 |
| sourceCells | Cells | 源单元格集合 |
| sourceRowIndex | int | 源行索引 |
| destinationRowIndex | int | 目的地行索引 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.12 CreateRange
创建 range Range Cells.CreateRange(upperLeftCell,lowerRightCell); or Range Cells.CreateRange(firstIndex,unmber,isVertical); or Range Cells.CreateRange(firstRow,firstColumn,rowNumber,columnNumber); | |||
| 名称 | 值类型 | 说明 |
| upperLeftCell | string | 左单元格名称 |
| lowerRightCell | string | 右单元格名称 |
| firstIndex | int | 指定range首列或首行索引(行或列由isVertical确定) |
| unmber | int | 指定range首列或首行索引的偏移量(行或列由isVertical确定) |
| isVertical | bool | 是否垂直延伸;True为行,如果为行刚包含所有列;false为列; 如果为列刚包含所有行 |
| firstRow | int | 指定range首行索引 |
| firstColumn | int | 指定range首列索引 |
| rowNumber | int | 指定行索引偏移量 |
| columnNumber | int | 指定列索引偏移量 |
| |||
| 返回 | 说明 | |
| Range |
|
1.4.13 DeleteColumn +2
删除列 void Cells.DeleteColumn(columnIndex); and void Cells.DeleteColumn(columnIndex, updateReference); | |||
| 名称 | 值类型 | 说明 |
| columnIndex | int | 将要删除列索引 |
| updateReference | bool | 更新参考 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.14 DeleteRange
移除指定range内的单元格,并设置range外列的方向 void Cells.DeleteRange(stratRow,startColumn,endRow,endColumn,shiftType); | |||
| 名称 | 值类型 | 说明 |
| stratRow | int | 起始行 |
| startColumn | int | 起始列 |
| endRow | int | 结束行 |
| endColumn | int | 结束列 |
| shiftType | ShiftType –枚举 | range外列填充方向 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.15 DeleteRow
删除指定行 void Cells.DeleteRow(rowIndex); | |||
| 名称 | 值类型 | 说明 |
| rowIndex | int | 将要删除行索引 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.16 DeleteRows +2
删除指定行集合 void Cells.DeleteRows(rowIndex,rowNumber); and void Cells.DeleteRows(rowIndex,rowNumber,updateReference);; | |||
| 名称 | 值类型 | 说明 |
| rowIndex | int | 将要删除列索引 |
| rowNumber | int | 指定删除的行数目 |
| updateReference | bool | 更新参考 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.17 EndCellInColumn +2
void Cells.EndCellInColumn(columnIndex); and void Cells. EndCellInColumn(startRow,endRow,startColumn,endColumn); | |||
| 名称 | 值类型 | 说明 |
| columnIndex | byte |
|
| startRow | int |
|
| endRow | int |
|
| startColumn | byte |
|
| endColumn | byte |
|
| |||
| 返回 | 说明 | |
| void |
|
1.4.18 EndCellInRow +2
void Cells.EndCellInRow(rowIndex); and void Cells.EndCellInRow(startRow,endRow,startColumn,endColumn); | |||
| 名称 | 值类型 | 说明 |
| rowIndex | int |
|
| startRow | int |
|
| endRow | int |
|
| startColumn | byte |
|
| endColumn | byte |
|
| |||
| 返回 | 说明 | |
| void |
|
1.4.19 ExportArray
输出指定range单元格内容到 object二维数组中 object[,] Cells.ExportArray(firstRow,firstColumn,rowNumber,columnNumber); | |||
| 名称 | 值类型 | 说明 |
| firstRow | int | 首行 |
| firstColumn | int | 首列 |
| rowNumber | int | 行数目 |
| columnNumber | int | 列数目 |
| |||
| 返回 | 说明 | |
| object[,] |
|
1.4.20 ExportDataTable +4
输出指定range单元格内容到 DataTable中;每列单元格以统一格式导入到Excel,如果列所有单元格有不同格式的值,输出会报错 DataTable Cells.ExportDataTable(firstRow,firstColumn,rowNumber,columnNuber); Or DataTable Cells.ExportDataTable(firstRow,firstColumn,rowNumber,columnNuber,exportColumnName); Or DataTable Cells.ExportDataTable(firstRow,firstColumn,rowNumber,columnNumber,defaultValues); Or DataTable ExportDataTable(firstRow,firstColumn,rowNumber,columnNumber,exportColumnName,isVertical); | |||
| 名称 | 值类型 | 说明 |
| firstRow | int | 首行 |
| firstColumn | int | 首列 |
| rowNumber | int | 行数目 |
| columnNumber | int | 列数目 |
| exportColumnName | bool | 是否输出行名 |
| isVertical | bool | 如果isVertical为true,列转DataTable列 如果isVertical为false,列转DataTable行 |
| defaultValues | object[] | 输出默认值 |
| |||
| 返回 | 说明 | |
| DataTable |
|
1.4.21 ExportDataTableAsString +2
输出指定range单元格数据以字符串格式输出到 DataTable中 DataTable Cells. ExportDataTableAsString(firstRow,firstColumn,rowNumber,columnNumber); Or DataTable Cells.ExportDataTableAsString(firstRow,firstColumn,rowNumber,columnNumber, exportCloumnName) | |||
| 名称 | 值类型 | 说明 |
| firstRow | int | 首行 |
| firstColumn | int | 首列 |
| rowNumber | int | 行数目 |
| columnNumber | int | 列数目 |
| exportColumnName | bool | 是否输出行名 |
| |||
| 返回 | 说明 | |
| DataTable |
|
1.4.22 ExportTypeArray
输出指定range单元格数据类型 至CellValueType二维数组中 CellValueType[,] Cells.ExportTypeArray(firstRow,firstColumn,rowNumber,columnNumber); | |||
| 名称 | 值类型 | 说明 |
| firstRow | int | 首行 |
| firstColumn | int | 首列 |
| rowNumber | int | 行数目 |
| columnNumber | int | 列数目 |
| |||
| 返回 | 说明 | |
| CellValueType[,] | 返回每个单元格数据类型 |
1.4.23 FindFormula
返回当前工作表中公式和formula相同的第一个单元格 Cell Cells.FindFormula(formula,previousCell); | |||
| 名称 | 值类型 | 说明 |
| formula | string | Excel公式 |
| previousCell | Cell |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.24 FindFormulaContains
返回当前工作表中公式包含formula字符串的第一个单元格 Cell Cells.FindFormulaContains(formula,previousCell); | |||
| 名称 | 值类型 | 说明 |
| formula | string | 公式字符串;例:”=”,”SUM”等 |
| previousCell | Cell |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.25 FindNumber +2
返回当前工作表中单元格格式为数值型并值为inputString的第一个单元格 Cell Cells.FindNumber(inputNumber,previousCell); Or Cell Cells.FindNumber(inputNumber,previousCell); | |||
| 名称 | 值类型 | 说明 |
| inputNumber | Double Or int | 公式字符串;例:”=”,”SUM”等 |
| previousCell | Cell |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.26 FindString +3
返回当前工作表中单元格格式为字符串型并值为inputString的第一个单元格 Cell Cells.FindString(inputString,previousCell); Or Cell Cells.FindString(inputString,previousCell,upDown); Or Cell Cells.FindString(inputString,previousCell,area); | |||
| 名称 | 值类型 | 说明 |
| inputString | string | 查询单元格值 |
| previousCell | Cell |
|
| upDown | bool |
|
| area | CellArea |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.27 FindStringContains +3
返回当前工作表中单元格格式为字符型并值包含inputString的第一个单元格 Cell Cells. FindStringContains (inputString,previousCell); Or Cell Cells. FindStringContains (inputString,previousCell,isCaseSensitive); Or Cell Cells. FindStringContains(inputString,previousCell,isCaseSensitive,area); | |||
| 名称 | 值类型 | 说明 |
| inputString | string | 查询单元格包含的值 |
| previousCell | Cell |
|
| isCaseSensitive | bool |
|
| area | CellArea |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.28 FindStringEndsWith
返回当前工作表中单元格格式为字符串并值尾部位置为 inputString的第一个单元格 Cell Cells. FindStringEndsWith (inputString,previousCell); | |||
| 名称 | 值类型 | 说明 |
| inputString | string | 查询单元格包含的值 |
| previousCell | Cell |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.29 FindStringStartsWith
返回当前工作表中单元格格式为字符串并值头部位置为 inputString的第一个单元格 Cell Cells. FindStringStartsWith(inputString,previousCell); | |||
| 名称 | 值类型 | 说明 |
| inputString | string | 查询单元格包含的值 |
| previousCell | Cell |
|
| |||
| 返回 | 说明 | |
| Cell |
|
1.4.30 GetColumnWidth
获取指定列的列宽 double Cells.GetColumnWidth(column); | |||
| 名称 | 值类型 | 说明 |
| column | int | 列索引 |
| |||
| 返回 | 说明 | |
| double |
|
1.4.31 GetColumnWidthPixel
获取指定列的列宽以像素为单位 int Cells.GetColumnWidthPixel(column); | |||
| 名称 | 值类型 | 说明 |
| column | int | 列索引 |
| |||
| 返回 | 说明 | |
| int |
|
1.4.32 GetEnumerator
获取统计员实体 IEnumerator Cells.GetEnumerator(); | |||
| 名称 | 值类型 | 说明 |
| column | int | 列索引 |
| |||
| 返回 | 说明 | |
| IEnumerator |
|
1.4.33 GetRowHeight
获取行高度 double Cells.GetRowHeight(row); | |||
| 名称 | 值类型 | 说明 |
| row | int | 行索引 |
| |||
| 返回 | 说明 | |
| double |
|
1.4.34 GetRowHeightPixel
获取行高度以像素为单位 int Cells.GetRowHeightPixel(row); | |||
| 名称 | 值类型 | 说明 |
| row | int | 行索引 |
| |||
| 返回 | 说明 | |
| int |
|
1.4.35 GroupColumns +2
列分组(不带求合) void Cells.GroupColumns(firstIndex,lastIndex); or void Cells.GroupColumns(firstIndex,lastIndex,isHidden) | |||
| 名称 | 值类型 | 说明 |
| firstIndex | int | 列索引 |
| lastIndex | int | 统计列索引偏移量; |
| isHidden | bool | 是否隐藏 |
| |||
| 返回 | 说明 | |
| int |
|
1.4.36 GroupRows +2
行分组(不带求合) void Cells.GroupRows(firstIndex,lastIndex); or void Cells.GroupRows(firstIndex,lastIndex,isHidden) | |||
| 名称 | 值类型 | 说明 |
| firstIndex | int | 行索引 |
| lastIndex | int | 统计行索引偏移量;; |
| isHidden | bool | 是否隐藏 |
| |||
| 返回 | 说明 | |
| int |
|
1.4.37 HideColumn
隐藏列 void Cells.HideColumn(column); | |||
| 名称 | 值类型 | 说明 |
| column | int | 列索引 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.38 HideRow
隐藏行 void Cells.HideRow(row); | |||
| 名称 | 值类型 | 说明 |
| row | int | 行索引 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.39 ImportArray +6
将数组导入至工作表中 void Cells.ImportArray(doubleArray,firstRow,firstColumn); or void Cells.ImportArray(intArray,firstRow,firstColumn); Or void Cells.ImportArray(stringArray,firstRow,firstColumn); Or void Cells.ImportArray(doubleArray,firstRow,firstColumn,isVertical); Or void Cells.ImportArray(intArray,firstRow,firstColumn,isVertical); Or void Cells.ImportArray(stringArray,firstRow,firstColumn,isVertical); | |||
| 名称 | 值类型 | 说明 |
| doubleArray | double[,] or double[] | 导入数据源 |
| intArray | int[,] or int[] | 导入数据源 |
| stringArray | string[,] or string[] | 导入数据源 |
| firstRow | Int | 起始行 |
| firstColumn | int | 起始列 |
| isVertical | bool | 导入工作表方向,true为坚向,false为横向 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.40 ImportArrayList
将arrayList导入至工作表中 void Cells.ImportArrayList(arrayList,firstRow,firstColumn,isVertical);); | |||
| 名称 | 值类型 | 说明 |
| arrayList | System.Collections.ArrayList | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | byte | 起始列 |
| isVertical | bool | 导入工作表方向,true为坚向,false为横向 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.41 ImportDataColumn +4
指定dataTable/ dataView某列名称或列名称索引 导入到指定位置 void Cells.ImportDataColumn(dataTable,isFieldNameShown,firstRow,firstColumn,importColumnIndex, insertRows); or void Cells.ImportDataColumn(dataTable,isFieldNameShown,firstRow,firstColumn,importColumnName, insertRows); or void Cells.ImportDataColumn(dataTable,ifFieldNameShown,firstRow,firstColumn,importColumnIndex, insertRows,defaultValue); or void Cells.ImportDataColumn(dataView,isFieldNameShown,firstRow,firstColumn,importColumnIndex ,insertRows); | |||
| 名称 | 值类型 | 说明 |
| dataTable | DataTable | 数据源 |
| dataView | DataView | 数据源 |
| isFieldNameShown | bool | 是否写入表头 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| importColumnIndex | Int | DataTable列索引编号下标从0开始 |
| importColumnName | string | DataTable列名称 |
| insertRows | bool | 是否为插入行 |
| defaultValue | object | 默认值 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.42 ImportDataGrid +2
将DataGrid导入至工作表中 int Cells.ImportDataGrid(dataGrid,firstRow,firstColumn,insertRows); or int Cells.ImportDataGrid(dataGrid,firstRow,firstColumn,rowNumber,columnNumber,insertRows); | |||
| 名称 | 值类型 | 说明 |
| dataGrid | DataGrid | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | byte | 起始列 |
| rowNumber | int | 指定导入行数; 最大行数等于dataGrid行数 |
| columnNumber | int | 指定导入列数; 最大列数等于dataGrid列数 |
| insertRows | bool | 是否为插入行 |
| |||
| 返回 | 说明 | |
| int | 返回插入行 |
1.4.43 ImportDataGridAsString
将DataGrid值以字符串形式导入至工作表中 int Cells.ImportDataGridAsString(dataGrid,firstRow,firstColumn,insertRows); | |||
| 名称 | 值类型 | 说明 |
| dataGrid | DataGrid | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | byte | 起始列 |
| rowNumber | int | 指定导入行数; 最大行数等于dataGrid行数 |
| columnNumber | int | 指定导入列数; 最大列数等于dataGrid列数 |
| insertRows | bool | 是否为插入行 |
| |||
| 返回 | 说明 | |
| int | 返回插入行 |
1.4.44 ImportDataRow
将DataRow导入至指定位置 void Cells.ImportDataRow(dataRow,row,firstColumn); | |||
| 名称 | 值类型 | 说明 |
| dataRow | DataRow | 数据源 |
| row | int | 起始行 |
| firstColumn | byte | 起始列 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.45 ImportDataTable +8
将DataTable从指定位置导入 int Cells.ImportDataTable(dataTable, isFieldNameShown,startCell); or int Cells.ImportDataTable(dataTable,isFieldNameShown,firstRow,firstColumn); or int Cells.ImportDataTable(dataTable,isFieldNameShown,firstRow,firstColumn,insertRows); or int Cells.ImportDataTable(dataTable,isFieldNameShown,firstRow,firstColumn,insertRows, convertStringToNumber); or int Cells.ImportDataTable(dataTable,isFieldNameShown,firstRow,firstColumn,rowNumber,columnNumber); or int Cells.ImportDataTable(dataTable,isFileldNameShown,firstRow,firstColumn,rowNumber,columnNumber, insertRows); or int Cells.ImportDataTable(dataTable,isFileldNameShown,firstRow,firstColumn,rowNumber,columnNumber, insertRows, dateFormatString); or int Cells.ImportDataTable(dataTable,isFileldNameShown,firstRow,firstColumn,rowNumber,columnNumber, insertRows, dateFormatString,convertStringToNumber); | |||
| 名称 | 值类型 | 说明 |
| dataTable | DataTable | 数据源 |
| isFieldNameShown | bool | 是否写入表头 |
| startCell | string | 起始单元格名称;例:A3 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| insertRows | bool | 是否为插入行 |
| convertStringToNumber | bool | 是否将dataTable中字符型数值转换为数值型数值 |
| rowNumber | int | 导入行数目 |
| columnNumber | int | 导入列数目 |
| dateFormatString | string | dataTable中日期类型在工作表中显示日期格式 |
| |||
| 返回 | 说明 | |
| int | 返回导入行数 |
1.4.46 ImportDataView +7
将DataView导入至指定位置 int Cells.ImportDataView(dataView,firstRow,firstColumn); or int Cells.ImportDataView(dataView,firstRow,firstColumn,insertRows); Or int Cells.ImportDataView(dataView,isFieldNameShown,firstRow,firstColumn,insertRows); Or int Cells.ImportDataView(dataView,firstRow,firstColumn,rowNumber,columnNumber); Or int Cells.ImportDataView(dataView,firstRow,firstColumn,rowNumber,columnNumber,insertRows); Or int Cells.ImportDataView(dataView,isFieldNameShown,firstRow,firstColumn,rowNumber, columnNumber, insertRows); Or int Cells.ImportDataView(dataView,isFieldNameShown,firstRow,firstColumn,rowNumber,columnNumber, insertRows,numberFormatString);
| |||
| 名称 | 值类型 | 说明 |
| dataView | DataView | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | byte | 起始列 |
| insertRows | bool | 是否为插入行 |
| isFieldNameShown | bool | 是否写表头 |
| rowNumber | int | 导入行数目 |
| columnNumber | int | 导入列数目 |
| numberFormatString | string | 自定义格式 |
| |||
| 返回 | 说明 | |
| int | 返回插入成功行数 |
1.4.47 ImportFormulaArray
将string[]导入至指定位置 void Cells.ImportFormulaArray(stringArray,firstRow,firstColumn,isVertical); | |||
| 名称 | 值类型 | 说明 |
| stringArray | string[] | Excel公式 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| isVertical | bool | 如果isVertical为true,以列写入 如果isVertical为false,以行写入 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.48 ImportFromDataReader +3
将DataReader导入至指定位置 int Cells.ImportFromDataReader(oleReader,firstRow,firstColumn, insertRows); or int Cells.ImportFromDataReader(oleReader,isFieldNameShown,firstRow,firstColumn,insertRows); or int Cells.ImportFromDataReader(sqlReader,firstRow,firstColumn,insertRows); or int Cells.ImportFromDataReader(sqlReader,isFieldNameShown,firstRow,firstColumn,insertRows); | |||
| 名称 | 值类型 | 说明 |
| oleReader | System.Data.OleDb.OleDbDataReader | OleDbDataReader |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| insertRows | bool | 是否插入行 |
| isFieldNameShown | bool | 是否写表头 |
| sqlReader | System.Data.SqlClient.SqlDataReader | SqlDataReader |
| |||
| 返回 | 说明 | |
| int | 返回插入成功行数 |
1.4.49 ImportGridView
将GridView导入至指定位置 只能导入GridView当前页面 int Cells.ImportGridView(gridView,firstRow,firstColumn,insertRows,conertStringTonumber,convertStyle); | |||
| 名称 | 值类型 | 说明 |
| gridView | GridView | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| insertRows | bool | 是否插入行 |
| conertStringTonumber | bool |
|
| convertStyle | bool |
|
| |||
| 返回 | 说明 | |
| int | 返回插入成功行数 |
1.4.50 ImportObjectArray
将object[]导入至指定位置 void Cells.ImportObjectArray(objArray, firstRow, firstColumn, isVertical) | |||
| 名称 | 值类型 | 说明 |
| objArray | object[] | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| isVertical | bool | 如果isVertical为true,以列写入 如果isVertical为false,以行写入 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.51 ImportTwoDimensionArray
将object[,]导入至指定位置 void Cells.ImportTwoDimensionArray(objArray, firstRow, firstColumn); | |||
| 名称 | 值类型 | 说明 |
| objArray | object[,] | 数据源 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.53 InsertColumn +2
向工作表插入一列空列 void Cells.InsertColumn(columnIndex); or void Cells.InsertColumn(columnIndex,updateReference); | |||
| 名称 | 值类型 | 说明 |
| columnIndex | int | 将要插入的列索引 |
| updateReference | bool | 更新参考 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.54 InsertRange +3
向工作表插入range void Cells. InsertRange(area, shiftType); or void Cells. InsertRange(area, shiftNumber, shiftType); or void Cells. InsertRange(area,shiftNumber,shiftType,updateReference); | |||
| 名称 | 值类型 | 说明 |
| area | CellArea |
|
| shiftType | ShiftType –枚举 |
|
| shiftNumber | int | 替换数量 |
| updateReference | bool | 更新参考 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.55 InsertRow
向工作表插入一行空行 void Cells.InsertRow(rowIndex); | |||
| 名称 | 值类型 | 说明 |
| rowIndex | int | 将要插入的行索引 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.56 InsertRows +2
向工作表插入指定行数(空行) void Cells.InsertRows(rowIndex,rowNumber); or void Cells.InsertRows(rowIndex,rowNumber,updateReference); | |||
| 名称 | 值类型 | 说明 |
| rowIndex | int | 将要插入的行索引 |
| rowNumber | int | 插入指定行数 |
| updateReference | bool | 更新参考 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.57 MaxDataRowInColumn
获取指定列最大行 int Cells.MaxDataRowInColumn(column); | |||
| 名称 | 值类型 | 说明 |
| column | int | 列索引 |
| |||
| 返回 | 说明 | |
| int | 返回行数,下标以0开始 |
1.4.58 Merge
合并单元格 void Cells.Merge(firstRow,firstColumn,rowNumber,columnNumber); | |||
| 名称 | 值类型 | 说明 |
| firstRow | int | 起始行 |
| firstColumn | int | 起始列 |
| rowNumber | int | 行偏移量 |
| columnNumber | int | 列偏移量 |
| |||
| 返回 | 说明 | |
| void |
|
1.4.59 SetColumnWidth
设置指定列的列宽 void Cells.SetColumnWidth(columna,width); | |||
| 名称 | 值类型 | 说明 |
| columna | int | 列索引 |
| width | do |