Home > database >  Consult the export EXCEL, how to set the cell format
Consult the export EXCEL, how to set the cell format

Time:10-02

Export data as the text type, I want to export, after the completion of every as a numeric set, and define each column decimal places respectively, consult everybody. What should I do?

CodePudding user response:

Find a dw2xls!!!!

CodePudding user response:

For the text format is DW2XLS, DW

CodePudding user response:

You can set the cell format, the exact nothing impression, can go to the vba programming to look inside,

CodePudding user response:

What forget, you can run macros in excel, look at the set format, then call to PB,

CodePudding user response:

Run -> tools -> macro to record a new macro
Then manually set the cell format (properties), set up after you click the stop recording macros, analysis of the recorded code

//-- -- -- -- -- -- -- -- -- the create destory -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
OLEObject OLE_ExcelA
OLE_ExcelA=Create OLEObject
Long ll_error=0
Ll_error=OLE_ExcelA. ConnectToNewObject (" excel. Application ")
If ll_error & lt;> 0 Then
Messagebox (gs_notice, 'can't open the excel)
Return
The Else
OLE_ExcelA. Visible=false
//string ls_error//a Boolean lb_error//long ll_error
OLE_ExcelA. Workbooks. Open (is_path)
Mle_2. Text=mle_2. Text + 'successful open' + sle_ea. Text + char (13) + char (10)
End the IF

OLE_ExcelA. Activeworkbook. Worksheets [1]. The cells (1, 1). The value="https://bbs.csdn.net/topics/this is the first SHEET"
OLE_ExcelA. Activeworkbook. Worksheets. [2] cells (1, 1). The value="HTTP://https://bbs.csdn.net/topics/this is the second SHEET"
OLE_ExcelA. Activeworkbook. Worksheets. [3] cells (1, 1). The value="HTTP://https://bbs.csdn.net/topics/this is the third SHEET"
OLE_ExcelA. Activeworkbook. Saveas (" c: \ multisheet. XLS ", 39)
OLE_ExcelA. ActiveWorkbook. The save ()
OLE_ExcelA. Quit ()
OLE_ExcelA. Workbooks. Close
OLE_ExcelA. DisConnectObject ()
Destroy OLE_ExcelA

//-- -- -- -- -- -- -- -- -- -- - copy & amp; Paste -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Ls_2='A' + string (ll_num) + ', '+ ls_ColA + string (ll_num)
OLE_ExcelA. ActiveSheet. Range (ls_2). Copy
OLE_ExcelA. Worksheets (ls_newsheet). Activate
Ls_1='A' + string (ll_result)
OLE_ExcelA. ActiveSheet. Range (ls_1). PasteSpecial

//-- -- -- -- -- -- -- -- -- the add a new sheet & amp; Named it -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Ll_sumSheet=OLE_ExcelA. Worksheets. Count
If ll_sumSheet & gt; 0 then
For ll_num=1 to ll_sumsheet
If OLE_ExcelA. Activeworkbook. Worksheets [ll_num]. Name=ls_newsheet Then
Messagebox (' hint: ', 'the same sheet name already exists, please rename sheet')
OLE_ExcelA. Quit ()
OLE_ExcelA. Workbooks. Close
OLE_ExcelA. DisConnectObject ()
Destroy OLE_ExcelA;
The return - 1
End the If
Next
OLE_ExcelA. Worksheets. The Add ()
OLE_Excela. ActiveWorkbook. Activesheet. Name=ls_newsheet
End the If

//-- -- -- -- -- -- -- -- set ColumnWidth, set RowHeight -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
OLE_Excela. ActiveSheet. The Columns (2). ColumnWidth=5
OLE_Excela. ActiveSheet. Rows (2). RowHeight=60

//-- -- -- -- -- -- -- -- select=& gt; The merge and merge=& gt; Unmerge -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
OLE_ExcelA. Range (' B1: L1). Select
OLE_ExcelA. Range (' B1: L1). The Merge
OLE_ExcelA. Range (' B1: L1) MergeCells=False//cancelled merger

//-- horizontal center. Vertical center. Automatic folding line. At the top of the line drawing. The bottom line drawing. The background color -- -- -- -- -- -- -- -- -- -- -- -- -- --
OLE_ExcelA. ActiveSheet. Range (ls_range). HorizontalAlignment=7
OLE_ExcelA. ActiveSheet. Range (ls_range). VerticalAlignment=2
OLE_ExcelA. Range (ls_range). WrapText=true
OLE_ExcelA. Range (ls_range) Borders (3) graphics.linestyle=1
OLE_ExcelA. Range (ls_range) Borders (3) Weight=2
OLE_ExcelA. Range (ls_range) Borders (4) graphics.linestyle=1
OLE_ExcelA. Range (ls_range) Borders (4). Weight=2
OLE_ExcelA. Range (' A3: I3). Interior. Color=RGB (128, 255, 255)
  • Related