You are viewing limited content. For full access, please sign in.

Question

Question

How to Add excel row for each values from token ?

SDK
asked on December 20, 2018 Show version history

Hello,

I want to add a row for each values from my token (multivalues).

My WF,

 

My code,

namespace WorkflowActivity.Scripting.ScriptSDK
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using GemBox.Spreadsheet;

    /// <summary>
    /// Offre une ou plusieurs méthodes qui peuvent être exécutées au moment de l'exécution de l'activité de scriptage du flux de travail.
    /// </summary>
    public class Script1 : RAScriptClass102
    {
        /// <summary>
        /// Cette méthode est exécutée quand l'activité est effectuée.
        /// </summary>
        protected override void Execute()
        {

            // Rédigez votre code ici. La propriété BoundEntryInfo accèdera à l'entrée, RASession obtiendra la section de Repository Access

            ///// crée le chemin

            SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        ExcelFile ef = new ExcelFile();
        ExcelWorksheet ws = ef.Worksheets.Add("Feuille 1");

        ws.Cells[0, 0].Value = "Name";


        ef.Save("C:\\Users\\user\\Desktop\\Dylan\\Tableau Excel\\Mon projet Excel.xlsx");

        }
    }
}

My result,

 

Thanks in advance !

 

0 0

Replies

replied on December 22, 2018

You have to loop over your multivalued field and fill your excel cells.

Here is a sample code.

 

FieldValueCollection FVC = new FieldValueCollection();
FVC = doc.GetFieldValues();
string sNum_cde = string.Empty();
for (int i = 0; i < FVC.Count; i++)
{
    string fieldName = FVC.PositionToName(i);
    object fieldVal = FVC[i];
    if (fieldName == "NUM_CDE") // Your multivalue field
    {
        FieldInfo fi = Field.GetInfo(fieldName, session);
        sNum_cde = fi.ValueToString(fieldVal);
        sNnum_cde = sNnum_cde.Replace('\n','|'); // Replace new line with a separator
        break;
    }
    sArr = Snum_cde.Split('|');
    if (sNum_cde != string.Empty)
    {
        for (int nInd = 0; nInd < sArr.Length; nInd++)
        {
            // Your code here to iterate Cells

        }
    }
}

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.