示例#1
0
        /// <summary>
        /// Preenche a planilha do template com os dados de uma <see cref="System.Data.DataTable"/>.
        /// </summary>
        /// <param name="p_sheet">Planilha do template.</param>
        /// <param name="p_table">Dados a serem preenchidos.</param>
        private void FillSheetWithDataTable(Spartacus.ThirdParty.SejExcel.gSheet p_sheet, System.Data.DataTable p_table)
        {
            Spartacus.Utils.Excel.Sheet v_info;
            string[] v_cells;
            string v_value;
            int k;

            v_info = new Spartacus.Utils.Excel.Sheet();
            v_info.v_name = p_sheet.Name;
            v_info.v_data = p_table;
            v_info.v_fixedrows = 0;

            v_cells = p_sheet.Row(0);
            if (int.TryParse(v_cells[0], out k))
                v_cells = p_sheet.Row(k);
            else
            {
                k = 1;
                v_cells = p_sheet.Row(k);
            }

            v_info.v_mapping = new System.Collections.Generic.Dictionary<int, string>();
            if (v_cells != null)
            {
                for (int i = 0; i < v_cells.Length; i++)
                {
                    if (!string.IsNullOrEmpty(v_cells[i]) && v_cells[i].Length > 1)
                        v_value = v_cells[i].Substring(0, 1);
                    else
                        v_value = v_cells[i];
                    if (v_value == "*")
                        v_info.v_mapping[i] = v_cells[i].Replace("*", "");
                }
                if (v_info.v_mapping.Count > 0)
                    v_info.v_fixedrows = k;
            }

            v_info.v_currentrow = v_info.v_fixedrows + 1;

            this.v_sheets.Add(v_info);

            p_sheet.SetSource(OnDataRow, v_info.v_fixedrows);
        }