Home > Software engineering >  Write the contents of bring MSFlexGrid1 border style to a spreadsheet
Write the contents of bring MSFlexGrid1 border style to a spreadsheet

Time:10-06

Dim xlsRowCount As an Integer, xlsColCount As Integer 'generated form the rows and columns of
Dim xlsApp As Excel. Application
Dim xlsBook As Excel. The Workbook
Dim xlsSheet As Excel. The Worksheet
Dim I, j As Integer
The Set xlsApp=CreateObject (" Excel. Application ")
The Set xlsBook=xlsApp. Workbooks. Add
The Set xlsSheet=xlsBook. Worksheets (1)
On the Error Resume Next
XlsRowCount=FlexGrid. Rows
XlsColCount=FlexGrid, Cols


With xlsSheet
'set the spreadsheet the width of the columns
For I=1 To xlsColCount + 0 'xlsColCount + 1 + 1 has said in the last column of the output in one column width 12.5 column, reduction is opposite
Columns (I). ColumnWidth=8 'every Chinese character about width of the 2 (in the case of the default 12 words)

Next


'set the height of the spreadsheet all
For I=1 To xlsRowCount 0
Rows (I). The RowHeight=18
Next

'to write the content of MSFlexGrid1 to spreadsheet
For I=0 To xlsRowCount - 1
For j=0 To xlsColCount - 1
Cells (I + 1, j + 1). The Value=https://bbs.csdn.net/topics/FlexGrid.TextMatrix (I, j)
With xlsApp. ActiveSheet. Range (" A1: k1000 "). The Borders
. Graphics.linestyle=1
Weight=2
End With
Next
Next
End With


XlsBook. SaveAs "D: \ SGXT \ query results. XLS" 'App. Path & amp; "\ Test. XLS" 'save, if you don't save the path and file name specified, the default endures under the "my documents" Book1. XLS
MsgBox "has exported file to D: \ SGXT \ query results. XLS done!" VbInformation, "tip"
XlsApp. Visible=True 'shows the spreadsheet
The Set xlsApp=Nothing 'return control to Excel
  • Related