当前位置: 首页>>代码示例>>C#>>正文


C# Spartacus.GetStream方法代码示例

本文整理汇总了C#中Spartacus.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# Spartacus.GetStream方法的具体用法?C# Spartacus.GetStream怎么用?C# Spartacus.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spartacus的用法示例。


在下文中一共展示了Spartacus.GetStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SheetToDataTable

        /// <summary>
        /// Converte uma planilha para uma <see cref="System.Data.DataTable"/>.
        /// </summary>
        /// <returns><see cref="System.Data.DataTable"/> com os dados contidos na planilha.</returns>
        /// <param name="p_package">Objeto de manipulação de arquivos Excel (XLSX).</param>
        /// <param name="p_sheet">Objeto de manipulação de planilhas Excel (XLSX).</param>
        /// <remarks>
        /// A primeira linha é considerada como nomes de colunas, e todas as células dessa linha devem estar preenchidas.
        /// Não pode haver linhas em branco acima, ou colunas em branco à esquerda dos dados a serem convertidos.
        /// </remarks>
        private System.Data.DataTable SheetToDataTable(Spartacus.ThirdParty.SejExcel.OoXml p_package, Spartacus.ThirdParty.SejExcel.gSheet p_sheet)
        {
            System.Data.DataTable v_table;
            System.Data.DataRow v_row = null;
            bool v_firstrow = true;
            bool v_datanode = false;
            bool v_istext = false;
            string v_cellcontent;
            double v_value;
            int v_col = -1;
            string v_columncontrol = "";
            System.Collections.ArrayList v_columnlist;

            v_table = new System.Data.DataTable(p_sheet.Name);
            v_columnlist = new System.Collections.ArrayList();

            try
            {
                using (System.Xml.XmlReader v_reader = System.Xml.XmlReader.Create(p_sheet.GetStream()))
                {
                    while (v_reader.Read())
                    {
                        switch (v_reader.NodeType)
                        {
                            case System.Xml.XmlNodeType.Element:
                                v_datanode = false;
                                switch (v_reader.Name)
                                {
                                    case "row":
                                        if (! v_firstrow)
                                        {
                                            v_row = v_table.NewRow();
                                            v_col = -1;
                                        }
                                        break;
                                    case "c":
                                        v_istext = false;
                                        while (v_reader.MoveToNextAttribute())
                                        {
                                            if (v_reader.Name == "t")
                                            {
                                                if (v_reader.Value == "s")
                                                    v_istext = true;
                                            }
                                            else
                                            {
                                                if (v_reader.Name == "r")
                                                {
                                                    if (v_reader.Value.Length > 1)
                                                    {
                                                        v_columncontrol = v_reader.Value;
                                                        v_col++;
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    case "v":
                                        v_datanode = true;
                                        break;
                                    default:
                                        break;
                                }
                                break;
                            case System.Xml.XmlNodeType.EndElement:
                                v_datanode = false;
                                if (v_reader.Name == "row")
                                {
                                    if (v_firstrow)
                                        v_firstrow = false;
                                    else
                                        v_table.Rows.Add(v_row);
                                }
                                break;
                            case System.Xml.XmlNodeType.Text:
                                if (v_datanode)
                                {
                                    if (v_istext)
                                        v_cellcontent = p_package.words [System.Int32.Parse(v_reader.Value)];
                                    else
                                        v_cellcontent = v_reader.Value;
                                    if (v_firstrow)
                                        this.AddColumn(v_columnlist, v_table, v_col, v_columncontrol, v_cellcontent);
                                    else
                                    {
                                        if (double.TryParse(v_cellcontent, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out v_value))
                                            v_row [this.ColumnIndex(v_columnlist, v_columncontrol)] = System.Math.Round(v_value, 8).ToString();
                                        else
                                            v_row [this.ColumnIndex(v_columnlist, v_columncontrol)] = v_cellcontent;
                                    }
//.........这里部分代码省略.........
开发者ID:lubota,项目名称:spartacus,代码行数:101,代码来源:Spartacus.Utils.Excel.cs


注:本文中的Spartacus.GetStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。