在上篇博客中写到关于Excel操作解析成相关的类,下面将写入一种Excel对Excel表格读取和写入. 对于Excel表格操作,最重要的是创建workBook.其操作顺序是: 1.获得WorkBook实例: Workbook workbook = WorkbookFactory.create(file); 2.获得每一个Sheet对象,也就是Excel表格的每一个表格 for (int i = 0; i < workbook.getNumberOfSheets(); i++) { Sheet s
1.得到当前格子中的内容:DBGrid1.Fields[DBGrid1.SelectedIndex].DisplayText;把DBGrid1.SelectedIndex改为你所希望引用的字段就可以了,如第3个字段. DBGrid1.Fields[3].DisplayText; 2.双击单元格触发不同事件 procedure TMainFrm.DBGrid1DblClick(sender:TObject); begin if dbgrid1.fields[dbgrid1.selectedInde
1.单元格所在行和列高亮 第一种方式 Private Sub worksheet_selectionchange(ByVal target As Range) Cells.Interior.ColorIndex = xlColorIndexNone target.EntireRow.Interior.ColorIndex = 6 target.EntireColumn.Interior.ColorIndex = 50 End Sub 第二种方式 Private Sub worksheet_sel