/ *我使用vb scrips编辑excel文件的原因是:excel文件将始终不同,但格式相同,用户不希望在工作簿上保存VBA宏。
我从第3列获取值,并在结尾处将这些值添加到第9列。
* /
Set xlApp=CreateObject("Excel.Application")
Set xlBook=xlApp.Workbooks.Open("filepath", 0, true)
xlApp.visible=true
Set xlSheet=xlBook.Worksheets("Proposal Spreadsheet")
row=xlSheet.UsedRange.Rows.Count
col=xlSheet.UsedRange.Columns.Count
dim i
For i=15 to xlSheet.UsedRange.Rows.Count
cell=xlSheet.Cells(i,3).Value
celli=xlSheet.Cells(i,9).Value+"("+cell+")" //I am combining column 3 with column 9
xlSheet.Cells(i,9).Value=celli
Next
xlBook.Save
xlApp.Run "Submit_To_iDesk"
xlBook.Close
xlApp.Quit
Set xlApp=Nothing
Set xlBook=Nothing
WScript.Quit
答案 0 :(得分:1)
如果NSDictionary *oldDict = (NSDictionary *)[dataArray objectAtIndex:0];
NSMutableDictionary *newDict = [NSMutableDictionary dictionaryWithDictionary:oldDict];
[newDict setObject:@"Don" forKey:@"Name"];
[dataArray replaceObjectAtIndex:0 withObject:newDict];
没有返回有用的数字,请使用一种更可靠的方法来查找列中最后使用过的单元格:
UsedRange
答案 1 :(得分:1)
加快程序的关键是减少写入操作的次数 我就是这样做的
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Users\best buy\Desktop\Book1.xlsx", 0, True)
xlApp.Visible = True
xlApp.ScreenUpdating = False
Set xlSheet = xlBook.Worksheets("Proposal Spreadsheet")
Dim i, values, LastRow, target
With xlSheet
LastRow = xlSheet.UsedRange.Rows.Count
Set target = .Range(.Cells(15, 9), .Cells(LastRow, 9))
values = target.Value
For i = LBound(values, 1) To UBound(values, 1)
values(i, 1) = values(i, 1) & "(" & .Cells(i + 15 - LBound(values, 1), 3) & ")"
Next
target.Value = values
End With
xlBook.Save
'xlApp.Run "Submit_To_iDesk"
xlBook.Close
xlApp.ScreenUpdating = True
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing
WScript.Quit