eBiss 3

Hilfe & Dokumentation

User Tools

Site Tools


en:transformation:mappings:funktionen:custom:excelloadtab

XPath structure as result

Mapping functions can return a type of IMapObjectRoot that can be used in further x-path operations, see also eBiss.Excel.LoadTab.

namespace eBiss
{
    public class Excel : IMapFunctionExtender, ILoggingObject
    {
        public ILogContext Log
        {
            get;
 
            set;
        }
 
        [eBiss.Api.MappingFunction]
        public object LoadTab(string filename)
        {
            Log?.Trace($"Call eBiss.Excel.LoadTab('{filename}')");
 
            ExcelLoadResult result = new ExcelLoadResult();
 
            ... 
 
                for (int i = 1; i < table.Rows.Count; i++)
                {
                    DataRow row = table.Rows[i];
                    if (i == 1)
                    {
                        result.Header.Columns = ParseItemArray(row.ItemArray.Skip(keyColumn).ToArray());
                    }
                    else
                    {
                        ExcelLoadItem elItem = new ExcelLoadItem();
						foreach (string item in Array.ConvertAll(row.ItemArray.Skip(keyColumn + 1).ToArray(), o => o.ToString()))
						{
							elItem.Values.Add(new StringValue(item));
						}
				   }
			}
 
            return result;
        }
		...
    }
 
    public class ExcelLoadResult : IMapObjectRoot
    {
        public ExcelHeader Header = new ExcelHeader();
 
        public List<ExcelLoadItem> Entries = new List<ExcelLoadItem>();
    }
 
    public class ExcelHeader : IMapObjectItem
    {
        public List<StringValue> Columns;
    }
 
 
    public class ExcelLoadItem : IMapObjectItem
    {
        public string Key;
        public List<StringValue> Values;
    }
 
    public class StringValue : IMapObjectItem
    {
        public StringValue()
        {
 
        }
 
        public StringValue(string value)
        {
            this.Value = value;
        }
 
        public string Value;
    }
}
en/transformation/mappings/funktionen/custom/excelloadtab.txt · Last modified: 2024/02/20 08:15 by 127.0.0.1