以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 参数错误。 (异常来自 HRESULT:0x80070057 (E_INVALIDARG)) (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=168895) |
-- 作者:tongke -- 发布时间:2021/5/26 11:07:00 -- 参数错误。 (异常来自 HRESULT:0x80070057 (E_INVALIDARG)) .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.5.29.8 错误所在事件:窗口,主窗口,Button1,Click 详细错误信息: 参数错误。 (异常来自 HRESULT:0x80070057 (E_INVALIDARG)) 程序运行就提示这个,是不是.net的问题
|
-- 作者:有点蓝 -- 发布时间:2021/5/26 11:10:00 -- 错误所在事件:窗口,主窗口,Button1,Click 贴出代码说明 |
-- 作者:tongke -- 发布时间:2021/5/26 11:11:00 -- DataTables("通勤车乘车人员名单").DeleteFor("[序号] <> 0") DataTables("扣款打印").DeleteFor("[单位名称] <> \'\'") Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "excel文件|*.xlsx" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim Bk As New XLS.Book(dlg.FileName) Dim St1 As XLS.Sheet = Bk.Sheets(0) \'排序 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.Columns("A:P") ws.range("a2:P" & St1.Rows.Count).sort(key1:=Ws.Range("G3"),header:= MSExcel.XlYesNoGuess.xlyes,Orientation:= MSExcel.XlSortOrientation.xlSortColumns) wb.save wb.close \'开始导入 Dim Book As New XLS.Book(dlg.FileName) Dim Sheet1 As XLS.Sheet = Book.Sheets(0) Dim PBar1 As WinForm.ProgressBar = e.Form.Controls("ProgressBar1") PBar1.Maximum = Sheet1.Rows.Count Dim ygxm,bmmc,xm,yggh,zhiwei As String Dim r As Integer r = 2 Dim xh As Integer xh = 0 Do While Sheet1(r,2).Text <> "" Dim dr As DataRow dr = DataTables("通勤车乘车人员名单").AddNew() If bmmc <> Sheet1(r,6).Text Then Dim drr As DataRow drr = DataTables("扣款打印").AddNew() drr("单位名称") = sheet1(r,6).text xh = 1 Else xh = xh + 1 End If yggh = Sheet1(r,0).Text ygxm = Sheet1(r,2).Text bmmc = Sheet1(r,6).Text zhiwei = Sheet1(r,7).Text xm = ygxm.Replace(bmmc,"") dr("序号") = xh dr("部门名称") = bmmc dr("姓名") = xm dr("员工工号") = yggh dr("职位") = zhiwei PBar1.Value = r r = r + 1 Loop DataTables("通勤车乘车人员名单").Save() DataTables("扣款打印").DataRows(0).Delete() \'删除第一行空行 \'统计人数 Dim i As Integer Dim dr1 As DataRow For i = 0 To DataTables("扣款打印").DataRows.Count - 1 dr1 = DataTables("扣款打印").DataRows(i) Dim dwmc As String dwmc = dr1("单位名称") dr1("人数") = DataTables("通勤车乘车人员名单").Compute("Count(部门名称)","[部门名称] = \'" & dwmc & "\'") dr1("大写金额") = CUMoney(dr1("人数") * 10) Next DataTables("扣款打印").Save() MessageBox.Show("导入完成!", "提示") End If
|
-- 作者:有点蓝 -- 发布时间:2021/5/26 11:16:00 -- 试试 …… If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 \'排序 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 Rg1 As MSExcel.Range = Ws.UsedRange Dim Rg As MSExcel.Range = Ws.Columns("A:P") ws.range("a2:P" & Rg1.Rows.Count).sort(key1:=Ws.Range("G3"),header:= MSExcel.XlYesNoGuess.xlyes,Orientation:= MSExcel.XlSortOrientation.xlSortColumns) wb.save wb.close App.quit \'开始导入 Dim Book As New XLS.Book(dlg.FileName) Dim Sheet1 As XLS.Sheet = Book.Sheets(0) Dim PBar1 As WinForm.ProgressBar = e.Form.Controls("ProgressBar1") …… 或者全部改为使用vba导入数据,如:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=65686&skin=0 |
-- 作者:tongke -- 发布时间:2021/5/28 10:00:00 -- 找到原因了,是用户电脑上装的wps,xls文件默认用wps打开,我把wps卸载后问题解决了 |