gpt4 book ai didi

vb.net - Excel 保存在 C :\\MyDocuments Defaultly

转载 作者:行者123 更新时间:2023-12-04 22:10:59 25 4
gpt4 key购买 nike

我正在将数据导出到 excel 并尝试保存到我的应用程序中的文件夹......但 excel 默认保存在 C:\Documents 但我想保存在 E:\Apllication\Reports

这是我生成excel表的代码

    If ComDset.Tables(0).Rows.Count > 0 Then

Try
With Excel
.SheetsInNewWorkbook = 1
.Workbooks.Add()
.Worksheets(1).Select()

Dim i As Integer = 1
For col = 0 To ComDset.Tables(0).Columns.Count - 1
.cells(1, i).value = ComDset.Tables(0).Columns(col).ColumnName
.cells(1, i).EntireRow.Font.Bold = True
i += 1
Next
i = 2
Dim k As Integer = 1
For col = 0 To ComDset.Tables(0).Columns.Count - 1
i = 2
For row = 0 To ComDset.Tables(0).Rows.Count - 1
.Cells(i, k).Value = ComDset.Tables(0).Rows(row).ItemArray(col)
i += 1
Next
k += 1
Next
filename = "ShiftReport" & Format(MdbDate, "dd-MM-yyyy") & ".xls"
.ActiveCell.Worksheet.SaveAs(filename)
End With
System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
Excel = Nothing
Catch ex As Exception
MsgBox(ex.Message)
End Try

' The excel is created and opened for insert value. We most close this excel using this system
Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
For Each i As Process In pro
i.Kill()
Next
End If

并告诉我如何为标题分配颜色

提前致谢

最佳答案

你试过这个吗?

.ActiveCell.Worksheet.SaveAs("E:\Apllication\Reports\" & filename)

关于vb.net - Excel 保存在 C :\\MyDocuments Defaultly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1367484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com