我正在研究关闭已打开的Exceldocument的函数。 这就是我打开它的方式:
let xlApp = new Excel.ApplicationClass()
let xlWorkBookInput = xlApp.Workbooks.Open(@"C:\Projects\Tool\Versuch\VersuchZuEditieren.xlsx")
let viewStateMachine state event =
match state, event with
| {State = _}, ConsumablesClicked vm ->
view.HandleModelChanged { Title = "My Title"; Comment = sprintf "" }
let TrackPosition = vm.TrackPosition
let xlWorkSheetInput = xlWorkBookInput.Worksheets.["Consumables"] :?> Excel.Worksheet
let array = vm.TubePosition.Split([|','|])
let arrayLength = array.Length
let addIndex = sprintf "%s%d"
let randomNumber = System.Random()
for i in 0 .. arrayLength - 1 do
xlWorkSheetInput.Cells.[startindex + i + 2, 1] <- vm.TrackPosition
xlWorkSheetInput.Cells.[startindex + i + 2, 2] <- array.[i]
let randomBarcodePart2 = randomNumber.Next(000000, 999999)
xlWorkSheetInput.Cells.[startindex+ i + 2, 3] <- sprintf "%s%06d" vm.FixBarcodePart randomBarcodePart2
startindex <- startindex + arrayLength
{ State = "Consumables" }
在这里我会关闭它,但是如何?
答案 0 :(得分:1)
根据讨论中的评论,可以使用
关闭Excel文档xlApp.Workbooks.Close()