您能否提供使用 MS Word 将以下 VB 代码转换为使用 Aspose Word 的 VB.NET 的代码?
Dim os AS Excel.Worksheet
oS.Range("A55", "S55").Select()
oS.Application.Selection.Copy()
oS.Application.Selection.Insert(Shift:=Excel.XlDirection.xlDown)
最重要的是和最良好的祝愿。
您能否提供使用 MS Word 将以下 VB 代码转换为使用 Aspose Word 的 VB.NET 的代码?
Dim os AS Excel.Worksheet
oS.Range("A55", "S55").Select()
oS.Application.Selection.Copy()
oS.Application.Selection.Insert(Shift:=Excel.XlDirection.xlDown)
最重要的是和最良好的祝愿。
当您处理 Excel 文件时,您似乎对 Aspose.Cells API 的代码而不是 Aspose.Words API 感兴趣。
好吧,根据您的共享代码,您将获得一系列单元格,并使用“Shift Cells Down”选项将单元格复制到同一选定位置。您可以将其转换为 Aspose.Cells 代码,如下所示:
'Open the Source Excel file
Dim workbook As New Workbook("C:\Test_File.xlsx")
'get cells collection of first worksheet
Dim cells As Cells = workbook.Worksheets(0).Cells
'get the source range to copy
Dim sourceRange As Range = cells.CreateRange("A55:S55")
'Insert the range below the source range
Dim ca As CellArea = CellArea.CreateCellArea("A56", "S56")
cells.InsertRange(ca, ShiftType.Down)
' Move Source Range one Row down as Copy process has Shift Cells Down option selected
' this is only required if you have a named range and want it shifted as in Excel
sourceRange.MoveTo(55, 0)
'create destination range
Dim destinationRange As Range = cells.CreateRange("A55:S55")
'Copy the source range data to desitnation range (newly inserted range)
destinationRange.Copy(sourceRange)
'save the resultant file
workbook.Save("C:\Test_Out.xlsx")
希望上面的代码对您的实现有所帮助。