Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

import excel doc, the display in proper format

$
0
0
Hey guys,
Just trying to increase my programming ability atm so any help would be much appreciate.

In my asp.net project i've used (aspx)
    <asp:Panel ID="Excel" runat="server">     
    </asp:Panel>



(aspx.cs)
    ExcelFile ef = new ExcelFile();
            string fileName = @"C:\\location of excel doc";
            ef.LoadXlsx(fileName, XlsxOptions.PreserveMakeCopy);
    
            StringBuilder sb = new StringBuilder();
    
            foreach (ExcelWorksheet sheet in ef.Worksheets)
            {
                sb.AppendLine();
                sb.AppendFormat("------{0}--------", sheet.Name);
    
                foreach (ExcelRow row in sheet.Rows)
                {
                    sb.AppendLine();
                    foreach (ExcelCell cell in row.AllocatedCells)
                    {
                        if (cell.Value != null)
                        {
                            Label x = new Label();
                            x.Text = cell.Value.ToString();
                            Excel.Controls.Add(x);
    
                            sb.AppendFormat("{0}({1})", cell.Value, cell.Value.GetType().Name);
                            sb.Append("\t");
                        }
                    }
                }
            }
    
            Console.WriteLine(sb.ToString());


This works fine but it displays the excel file as a big lump of text clumped together, I would appreciate it if someone could give me a tip or somewhere to get started on how to display the output in a nice table

thank you

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>