//文本框给单元格修改值
private void txt_formula_TextChanged(object sender, EventArgs e)
{
object newValue = new object();
newValue = ((TextBox)sender).Text;
this.axSpreadsheet.Selection.Cells.set_Value(XlRangeValueType.xlRangeValueDefault,newValue);
}
单元格自己修改没问题,一到文本框输入符号就异常,高手帮忙解决未处理 System.Runtime.InteropServices.COMException
Message="异常来自 HRESULT:0xE004002F"
Source="Microsoft.Office.Interop.Owc11"
ErrorCode=-536608721
StackTrace:
在 Microsoft.Office.Interop.Owc11.RangeClass.set_Value(Object RangeValueDataType, Object Value)
在 witjointStatement.frmMain.txt_formula_TextChanged(Object sender, EventArgs e) 位置 E:\Objects\witjointStatement\witjointStatement\frmMain.cs:行号 531
在 System.Windows.Forms.Control.OnTextChanged(EventArgs e)
在 System.Windows.Forms.TextBoxBase.OnTextChanged(EventArgs e)
在 System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
在 System.Windows.Forms.TextBoxBase.WndProc(Message& m)
在 System.Windows.Forms.TextBox.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
在 System.Windows.Forms.Control.WmCommand(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
在 System.Windows.Forms.Control.DefWndProc(Message& m)
在 System.Windows.Forms.Control.WmKeyChar(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.TextBoxBase.WndProc(Message& m)
在 System.Windows.Forms.TextBox.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 witjointStatement.Program.Main() 位置 E:\Objects\witjointStatement\witjointStatement\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
单个单元格,主要是TextBox里面输符号的问题,输别的都没问题
比如第一个输入=号 后面不管输入什么符号都报错
第一个不输=号 一切正常如果从单元格录入公式 TextBox显示正常 反之异常