生成excel文件,设定的线框为什么没有起作用呢?
代码如下:【运行的时候,数据是导出了的,但是线框没有显示出来,数据量少的时候偶尔可以正常显示!数据量多了就不显示线框了?麻烦老师看看】
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "EXCEL文件|*.xlsx" '设置筛选器
Dim Proc As New Process '定义一个新的Process
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
try
Tables(e.Form.Name & "_table2").SaveExcel(dlg.FileName,FileSys.GetName(dlg.FileName)) '保存文件
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
Rg.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous '边框线型
Rg.Borders.Weight = MSExcel.XlBorderWeight.xlThin'边框粗细
Rg.Borders.ColorIndex = 3'边框颜色
Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4)
Rg.EntireColumn.AutoFit '自动调整列宽
Rg.EntireRow.AutoFit '自动调整行高
App.Visible = False
wb.save
app.quit()
catch ex As exception
Dim ps As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("EXCEL")
For Each p As System.Diagnostics.Process In ps
p.kill
Next
End try
End If
Proc.File = dlg.FileName '指定要打开的文件
Proc.Start()
[此贴子已经被作者于2022/3/3 9:16:42编辑过]