I have a variable called amount from the SQL Server. I tried to writeline the variable that stores the amount and there’s the data inside it. The question is :
How to store it into string array variable?
Example :
Variable Amount = 1,2,3,4,5
I want to store it to string so it will be strArray = {1,2,3,4,5}
If I use add data row, will it output columns by columns instead rows by rows? See image below
I see you tried out the solution I offered in the other thread.
Your problem might be a little different. If I understand correctly you have a datatable with 3 columns:
Customer ID, Customer Name, Value(s)
Now you have varying requirements in your original post and your answers throughout the thread. You need to rethink and state clearly, what you actually need.
Ok, easy enough! Use Assign like this: YourStringArrayVariable = YourStringVariable.Split(","c)
If you use add data row, it will add new rows to your datatable and have your values in new rows instead of in new columns… Am I missing something?
Ok now, you want your array of values in one row to be in separate columns of one row. That is possible but not pretty! What do you do, if the first array has 2 values but the second array has 3 values?
The problems are:
You need to create new columns only once (2 values in the array, 2 extra columns)
However you cannot be sure how many values are in one array, so you need to check if you created a column already by keeping track of the index
Do you really need all the values in separate columns? It would be much easier to store the values in an array in the column values.
To be honest I am literally really stuck right now and can’t figure a solution for this.
Ok, easy enough! Use Assign like this:
YourStringArrayVariable = YourStringVariable.Split(","c)
This is how I declare a string Array variable and put inside it, am I right?
If you use add data row, it will add new rows to your datatable and have your values
in new rows instead of in new columns… Am I missing something?
To make I was thinking of using add data row with string variable inside it. Will it do
the job that the array of string will be putted in columns or still in rows?
Ok now, you want your array of values in one row to be in separate columns of one
row. That is possible but not pretty! What do you do, if the first array has 2 values
but the second array has 3 values?
The problems are:
You need to create new columns only once (2 values in the array, 2 extra columns)
However you cannot be sure how many values are in one array, so you need to
check if you created a column already by keeping track of the index
Do you really need all the values in separate columns? It would be much easier to
store the values in an array in the column values.
Yes this is the main problem. The value can be vary (can be between 1-60). See excel below :
Your answers are all over the place, I am even more confused now.
The formatting in your excel looks good, you have column names year/month and you have values in the rows. But what is the problem?! Also no clue what you mean by the Maturity Date stuff.
You need to rethink and state clearly, what you actually need.
Try to provide context of the process or focus on the input and desired output.
Input: DataTable from SQL query with x columns and y rows
Output: Printing the DataTable to Excel??? What do you need to do with the values next?
I have no time to help any more today. But if you elaborate your problem, others might be able to help.
I was trying to explain the probability ways it can be done because I don’t know how to do it. But I guess I will make it more simple then
Input : Data table from SQL Query contains customer_id, customer_name, value, maturity date
Output : I have to write the datatable to excel that is customer_id, customer_name, and value but the value is in columns and not rows
Well, my project is done without any error, and the output is as I expected… I just need to simplify it right now. Currently my robot is running for 1 hour and 15 minute.