如何转换 Excel 的画表格的宏?(0分)

尘莽

Unregistered / Unconfirmed
GUEST, unregistred user!
VB 里面是
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

但是,在转换成 delphi 的时候如何对应?
Selection.Borders -> ExcelApplication.Selection.Borders 的时候,
提示没有 Borders 类啊,恳请高手指点迷津
 
看看这一段,不知道能不能帮上忙
var
Range: Variant;
begin
if OpenDialog1.Execute then
begin
try
v:= CreateOleObject('Excel.Application');
v.Visible := CheckBox1.Checked;
v.Workbooks.Open(OpenDialog1.FileName);
Range := v.Workbooks[1].WorkSheets[1].Range['A2:G2'];//单元格从A2到M2
Range.Merge; //合并单元格
Range.Rows.RowHeight := 50; //设置行高
Range.Borders.LineStyle := 1; //加边框
Range.Columns[2].ColumnWidth := 12; // 设置列宽
Range.FormulaR1C1 := '合并区';
Range.HorizontalAlignment := 3;//xlCenter(水平对齐方式)
Range.VerticalAlignment := 2;//xlCenter(垂直对齐方式)
Range.Characters.Font.Name := '宋体'; //字体
Range.Characters.Font.FontStyle := '加粗';
Range.Characters.Font.Size := 15;
Range.Characters.Font.OutlineFont := False; //是否有下划线
Range.Characters.Font.ColorIndex := 0;//xlAutomatic; //颜色
except
Showmessage('初始化Excel失败,可能没装Excel,或者其他错误;请重起再试。');
v.DisplayAlerts := false;
v.Quit;
exit;
end;
end;
end;
 
to lus_liu
感謝[:D]
另請問怎樣在delphi中控制excel的顯示比例﹐如按原大小的70%顯示等。
我試過改動宏﹐但不行。勞你試試﹐謝。
 
接受答案了.
 
顶部