Home > Net >  With embedded SetParent Excel table, Excel table can't edit
With embedded SetParent Excel table, Excel table can't edit

Time:10-04

I have an application need to open the EXCEL in the application, then use SetParent embedded EXCEL table, EXCEL table there's no way to edit, please support a move each great god
Public Sub Open (fileName As a String, the editAble As Boolean)
Try
If mParentOfficeEdit. InvokeRequired Then
MParentOfficeEdit. Invoke (New Dele_Open AddressOf (Open), the New Object () {fileName, the editAble})
The Else

MEditAble=the editAble
Dim fi the As System. IO. The FileInfo=New System. IO. The FileInfo (fileName)
MCaption=fi. Name + "" + DateTime. Now. Ticks. The ToString ()
Deactivateevents=True
OpenFileName=fileName

'initialize the Word program
InitExcel ()

'to close the file
CloseDoc ()

MAppHwnd=FindWindow (" XLMAIN mCaption)

If mAppHwnd & gt; 0 Then
SetParent (mAppHwnd, mParentOfficeEdit. Handle. ToInt32 ())

Try
If mExcelApp Is Nothing Then
Throw New WordInstanceException ()
End the If
If mExcelApp. Workbooks Is Nothing Then
Throw New DocumentInstanceException ()
End the If
If Not mExcelApp Is Nothing AndAlso Not mExcelApp. Workbooks Is Nothing Then

MWorkbook=mExcelApp. Workbooks. Open (fileName, 0, False)
MExcelApp. Visible=True


Dim mySheet. As Microsoft Office. Interop. Excel. The Worksheet=CType (mWorkbook. Worksheets (1), Microsoft. Office. Interop. Excel. The Worksheet)
Dim localrange. As Microsoft Office. Interop. Excel. Range=CType (mySheet. Cells (1, 1), Microsoft. Office. Interop. Excel. Range)
Localrange. Activate ()

End the If
If mWorkbook Is Nothing Then
Throw New ValidDocumentException ()
End the If
Catch
End the Try

'
the Word to interfaceShowExcelToUi ()
OnResize ()
SetExcelActive ()

Deactivateevents=False
End the If
End the If

Catch the ex As Exception
Close ()

DisplaySystemMessage (" ", the ex, SystemMessageEnum ErrMessage) 'handling errors
End the Try
End Sub

CodePudding user response:

The building Lord remember how ready before the operation of the Excel components, can surf the Internet to find and have a look

CodePudding user response:

Come to support a move to help

CodePudding user response:

You can use the OLE or directly operated by the third party components to excel, such as NPOI spire. XLS, aspose etc. These are rather easy to use, also do not rely on office components,

CodePudding user response:

Upstairs is reasonable, the most began with ole, then using npoi, now with spire, each have each acutely eggs anyway,
  • Related