Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Slow generation of hyperlinks

$
0
0
Hi;
Currently trying to generate a medium size spreadsheet - trace file showing timestamps.

2015-07-14 15:42:02,829 DEBUG DataflowQueue.Core.Excel.BaseExcelGeneratorEPPlus - BaseGenerator Writing 408 Column Headers
2015-07-14 15:42:02,860 DEBUG DataflowQueue.Core.Excel.BaseExcelGeneratorEPPlus - BaseGenerator Start writing 5000 Data Rows
2015-07-14 15:42:03,063 DEBUG DataflowQueue.Core.Excel.BaseExcelGeneratorEPPlus - BaseGenerator Start writing 784471 cells
2015-07-14 15:42:05,657 DEBUG DataflowQueue.Core.Excel.BaseExcelGeneratorEPPlus - BaseGenerator Start writing 65550 hyperlinks
2015-07-14 15:45:02,069 DEBUG DataflowQueue.Core.Excel.BaseExcelGeneratorEPPlus - BaseGenerator End Generate

Question is:
Writing 784471 cells takes 2 seconds.
Writing 65550 hyperlinks takes just under three minutes.
            Log.Debug(string.Format("BaseGenerator Start writing {0} cells", cells.Count));
            foreach (var cell in cells)
                {
            WriteCell(cell);
                }  
   
            Log.Debug(string.Format("BaseGenerator Start writing {0} hyperlinks", hyperlinks.Count));
            foreach (var hyperlink in hyperlinks)
                {
            WriteHyperLink(hyperlink);
                }

            protected void WriteCell(Cell cell)
                {
                WriteCell(cell.RowIndex + 1, cell.ColumnIndex + 1, cell.Value);
                }

           protected IXLCell WriteCell(int row, int column, string cellData)
                {
                return Worksheet.Cell(row, column, cellData); //extension method
                }

           protected void WriteHyperLink(Cell hyperlink)
               {
               WriteCell(hyperlink.RowIndex + 1, hyperlink.ColumnIndex + 1, hyperlink.Value).Hyperlink.ExternalAddress =   new Uri(hyperlink.Value);
               }
Is there something I've missed with regards to generating hyperlinks- or is there an optimised way to create hyperlinks?

Thanks
Kern

Viewing all articles
Browse latest Browse all 1877

Trending Articles



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