出于某种原因,在尝试打印到平面文本文件时,我在每个值前面都有很多空格。
'append headers
Cells(start_row - 2, 1).Select
For i = 1 To ActiveCell.SpecialCells(xlLastCell).Column
If ActiveCell.Offset(0, 1).Column = ActiveCell.SpecialCells(xlLastCell).Column Then
Print #finalCSV, Cells(start_row - 2, i) & "\n",
Else
Print #finalCSV, Cells(start_row - 2, i) & ",",
End If
Next i
示例输出:
DC Capacity:hi, Resistive Capacity:lo, Resistive Capacity:hi, Reactive Capacity:lo,
有没有办法摆脱这些空间?
答案 0 :(得分:2)
Print #finalCSV, Cells(start_row - 2, i) & ",";
如果我正确记住我的VB,逗号会插入一个标签,而分号只会抑制换行符。
答案 1 :(得分:1)
Print #finalCSV, Trim(Cells(start_row - 2, i)) & ",",
答案 2 :(得分:0)
文森特的回答是正确的,但我想让它更清楚:
打印#finalCSV,Cells(start_row - 2,i)& “”,
会给出这种输出:
> DC Capacity:hi, Resistive Capacity:lo, Resistive
> Capacity:hi, Reactive Capacity:lo,
在句子末尾使用分号:
打印#finalCSV,Cells(start_row - 2,i)& “”;
会给你这个输出:
> DC Capacity:hi,Resistive Capacity:lo,Resistive Capacity:hi,Reactive
> Capacity:lo,