配列処理をして1行ずつ項目を加工しデータテーブルへ格納する

activities

#1

配列処理をして1行ずつ項目を加工しdatatableへ格納するしたいと思います。
inputのイメージ
input

outputのイメージ
output

Build data tableで格納用のテーブルを作成しfor each rowで1行ずつ各項目を加工後outputすることを
考えています。
add data rowが有効と思いましたが設定の仕方が恥ずかしながらわかりません。
また、inputとoutputにint32型がありますが配列のassginでの移送の時エラーとなります。
ご教示いただければと思います。

sample.xaml (17.9 KB)

解らない部分:


#2

@matrix99999 In ArrayRow Property pass this {month,center,kubun,komoku} and change kingaku from int type to string


#3

Thank you very much.

The following layout was defined with “build datatable”.
{month, center, kubun, komoku} is the first item at once.
“Kingaku” is the second item.
Exiting “for each row”, I am considering outputting to excel according to the layout created by “excel” with 2 items “build datatable”.

・ Information stored in “build datatable” is output timing with “write range”
・ In the “month” item, I would like to acquire a character string with “substring (4,2)”, but an error occurred in the array.

I would like to teach you again.

build


#4

@matrix99999 What error you are getting and what result you need in substring


#5

I am sorry that the explanation is not concrete.
assgin
ymonth = row (0) .substring (4, 2)
Extract 04 from 201804.
It is an error content

substring

I’m sorry.
I hope to tell you


#6

@matrix99999 Try this ymonth = row(0).substring(4)


#7

Thank you very much.
I get a similar error.


#8

@matrix99999 Check ymonth is string type or not


#9

I confirmed the excel taken in.
In excel, warning is issued as to whether it is text type or text format.

After this, another error will occur although it did as follows.
wk_ymonth = row (0) .tostring
ymonth = wk_ymonth.substring (4, 2)

error contents

sample has thrown an exception
Source: Assign
Message: Index was out of range. Check that the collection has values and the index is less than the size of the collection.
Exception Type: ArgumentOutOfRangeException
System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
Actual value was .
at System.String.Substring(Int32 startIndex, Int32 length)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


#10

I understood the cause of the error.
I also read the contents of the header.
The character string of the header item is Japanese.
It is a feeling that it was an error because the item name “date” was not enough.
However, when reading excel with “read range”, I unchecked “add headers”.
I’m sorry.
For each row, please teach about correspondence with write range by storing data in build datatable.


#11

It was dealt somehow.
There was a numeric type in the data read from excel.
Convert numbers to strings in arrays.
Create datatable of string type and numeric type with build datatable.
It writes one line at a time and stores the character string in numerical type defined by build datatable.
(Originally it is numeric type, but it is converted to character type)
After checking the excel you wrote, it changed to the numeric type defined in “build datatable”.
Although the result is good, it is doubtful that excel does not reflect the contents defined in build datatable