我使用vb .net进行了应用程序,当我在PC上使用应用程序时,一切正常,但是一旦我将应用程序复制到另一台PC,它就无法正常工作。
问题是来自应用程序的数据保存在Excel文件中。在Excel文件中,我得到了使用标准的公式SUM数据表。
当我在我的电脑上打开Excel文件时,此工作簿中的数据会自动更新。一旦我在另一台PC上打开文件,我必须选择带有公式编辑的单元格,然后按Enter键,然后更新数据。
这是我用来向Excel插入数据的代码:
Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=EXCEL_DATA\2SV REARS RFT.xlsx;Extended Properties = ""Excel 12.0 Xml;HDR=YES"""
'Create an INSERT INTO SQL statement
Dim insertStatement As String = "INSERT INTO [Sheet1$] ([Week], [Date], [Shift], [Frame Type], [Quantity], [Problem], [Weld Number], [Welder]) VALUES ('" + NOWEEK.Text + "','" + datee.Text + "','" + CHOSESHIFT.Text + "'," + FRAMETYPE.Text + "," + QUANTITY.Text + ",'" + PROBLEM.Text + "','" + WELDNUMBER.Text + "','" + WELDERNAME.Text + "')"
'Create a connection object to connect to the Excel Workbook
Dim connection As New OleDbConnection(connectionString)
'Create a command object that will execute the insert statement
Dim command As New OleDbCommand(insertStatement, connection)
'Open the connection, execute the statement and close the connection
connection.Open()
command.ExecuteNonQuery()
connection.Close()
'Dispose of the connection and command objects
connection.Dispose()
command.Dispose()
'Call the RefreshData routine so that you can see that data was indeed added.`enter code here`
这是Excel中用于汇总数据的公式:
=SUMIFS(Sheet1!E2:E4987,Sheet1!B2:B4987,Sheet4!B2,Sheet1!C2:C4987,"RED",Sheet1!D2:D4987,40%)
我发现,一旦将数据插入到Excel数据中,就会有数字excel要求我转换为数字。