Ejemplo n.º 1
0
        public LexPage(SpreadSheet xls, int no) : this(xls.GetSheet().name, no)
        {
            char endCol = (char)('A' + xls.GetRow(0).GetLastCellNum());

            for (char c = 'B'; c <= endCol; ++c)
            {
                columnTitles[xls.GetString1(1, c)] = c - 'B';
            }
            List <string> list = new List <string> ();

            for (int r = 1; r <= xls.GetSheet().GetLastRowNum(); ++r)
            {
                list.Clear();
                string key = xls.GetString1(r + 1, 'A').Trim();
                if (!key.IsEmpty())
                {
                    for (char c = 'B'; c <= endCol; ++c)
                    {
                        list.Add(xls.GetString1(r + 1, c));
                        // TODOM use filter instead of Replace
//						list.Add (xls.GetString(r+1, c).Replace("\\n", "\n"));
                    }
                    if (list.Count > 0)
                    {
                        string[] arr = list.ToArray();
                        if (sheet.ContainsKey(key))
                        {
                            log.Error("Duplicate key: {0}.{1}", name, key);
                        }
                        sheet[key] = arr;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void Load()
 {
     if (_rows != null)
     {
         return;
     }
     loader(path, b =>
     {
         if (b != null)
         {
             SpreadSheet ss  = new SpreadSheet(b);
             ss.allowNullRow = allowNullRow;
             ss.trimSpace    = trimSpace;
             if (_rows == null)
             {
                 _rows = ss.GetRows <R>(1);
             }
             else
             {
                 _rows.AddRange(ss.GetRows <R>(1));
             }
             _indexer = _rows.ToDictionary(GetKey);
             for (int i = 0; i < _rows.Count; ++i)
             {
                 ProcessRow(i + 1, _rows[i]);
             }
         }
         else
         {
             log.Warn("Can't access {0}", path);
         }
     });
 }
Ejemplo n.º 3
0
        public static void AddAltLexicon(byte[] b)
        {
            SpreadSheet xls = new SpreadSheet(b);

            while (xls.HasNextRow())
            {
                xls.NextRow();
                string key   = xls.GetNextCellString();
                string value = xls.GetNextCellString();
                if (key.IsEmpty())
                {
                    continue;
                }
                invAltMap[value] = key;
                if (!conflict.Contains(key))
                {
                    if (altMap.ContainsKey(key))
                    {
                        conflict.Add(key);
                    }
                    else
                    {
                        altMap[key] = value;
                    }
                }
            }
            if (log.IsLoggable(LogLevel.Log))
            {
                log.Debug("Duplicate Message Key: {0}", conflict.Join(","));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The first row of each sheet is considered as a title row
        /// </summary>
        /// <param name='asset'>
        /// Asset.
        /// </param>
        public void Add(byte[] bytes, SpreadSheetSourceType sourceType = SpreadSheetSourceType.CSV)
        {
            SpreadSheet xls = new SpreadSheet(bytes, sourceType);

            for (int i = 0; i < xls.GetSheetCount(); ++i)
            {
                xls.SetSheet(i);
                LexPage p = new LexPage(xls, pages.Count);
                p.SetLanguage(lang);
                pages.Add(p);
            }
            PageNo = 0;
        }