简体   繁体   English

如何使用蓝色棱镜将文本中的 fieldinfo 参数用于列代码

[英]How to use fieldinfo parameter in text to column code using blue prism

I am trying to use text to columns code using the blue prism code stage, I managed to do it in a good way but my results are in xlGeneralFormat but I want them in text format我正在尝试使用蓝色棱镜代码阶段的文本到列代码,我设法以一种很好的方式做到了,但我的结果是 xlGeneralFormat 但我希望它们是文本格式

Dim wb, ws As Object
Dim excel, sheet, range As Object



Try


wb = GetWorkbook(Handle, Workbook)
ws = GetWorksheet(Handle, Workbook, Worksheet)

wb.Activate()
ws.Activate()
excel = ws.Application
sheet = excel.ActiveSheet
range = sheet.Range(Reference)
range.Select()

excel.selection.TextToColumns (DataType:=1,ConsecutiveDelimiter:=True,Other:=True,OtherChar:="_",fieldinfo:= "Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 2), Array(8, 2), Array(9, 2), Array(4, 2), Array(5, 2))")

Success = True

Catch e As Exception
    Success = False
    Message = e.Message
Finally
    wb = Nothing
    ws = Nothing
    excel = Nothing
    sheet = Nothing
    range = Nothing
End Try

but it doesn't work !但它不起作用!

NB.注意。 The code works well without fieldinfo:= "Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 2), Array(8, 2), Array(9, 2), Array(4, 2), Array(5, 2))"该代码在没有fieldinfo:= "Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 2), Array(8, 2), Array(9, 2), Array(4, 2), Array(5, 2))"

but it's in xlGeneralFormat但它是xlGeneralFormat

Anybody Can help about this case?任何人都可以帮助解决这个案例吗?

Maybe you could change the column format just afterwards?也许您可以在之后更改列格式? Like this one:像这个:

sheet.Columns("A:B").NumberFormat = "@"

where you change the phrase "A:B" with the columns you want to format.您可以在其中使用要格式化的列更改短语“A:B”。 Or you could do this with a range:或者你可以用一个范围来做到这一点:

range.NumberFormat = "@"

Note: "@" is the code for text format.注意:“@”是文本格式的代码。

You could create an Integer matrix like this.您可以像这样创建一个 Integer 矩阵。

Dim matrix = New Integer(6, 1) {{1, 1}, {2, 1}, {3, 9}, {4, 1}, {5, 1}, {6, 1}, {7, 1}}

And use that as the parameter for FieldInfo并将其用作 FieldInfo 的参数

FieldInfo:=matrix

Full Code like this:像这样的完整代码:

Dim wb, ws As Object
Dim excel, sheet, range As Object
Dim matrix = New Integer(6, 1) {{1, 1}, {2, 1}, {3, 9}, {4, 1}, {5, 1}, {6, 1}, {7, 1}}

Try

wb = GetWorkbook(Handle, Workbook)
ws = GetWorksheet(Handle, Workbook, Worksheet)

wb.Activate()
ws.Activate()
excel = ws.Application

excel.Selection.TextToColumns (Destination:=excel.Range(Cell_Reference), DataType:=1, _
        TextQualifier:=-4142, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _      
        :=Delimiter, FieldInfo:=matrix, TrailingMinusNumbers:=True)

Success = True

Catch e As Exception
    Success = False
    Message = e.Message
Finally

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Delphi-> Delphi棱镜,如何使用记录数组? - Delphi -> Delphi prism, how to use array of records? C#FieldInfo.SetValue,带有数组参数和任意元素类型 - C# FieldInfo.SetValue with an array parameter and arbitrary element type 使用VBA中的FieldInfo动态格式化Workbook.OpenText上的列 - Dynamically format columns on Workbook.OpenText using FieldInfo in VBA 如何在 Arduino 代码的 function 参数中使用向量(数组)? - How to use a vector (array) in a function parameter on Arduino code? C#如何在不进行手动类型转换的情况下调用FieldInfo.SetValue函数 - C# How to call FieldInfo.SetValue function without manual type conversion “文本到列 - 固定宽度”的 VBA 代码 - 循环 - VBA code for "Text to Column - Fixed Width" - loop 如何在Code Igniter中使用batch_insert将数组插入1列PHP? - How to use batch_insert in Code Igniter to insert an array into 1 column PHP? 对Java(Blue J)中的ArrayLIst使用for循环? - Using for loop for an ArrayLIst in Java (Blue J)? 如何将文本列表格式化为 2 列 - How to formatting list of text into 2 column 如何在for循环中使用数组中的先前参数 - How to use previous parameter from array in for loop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM