Excel catalyst wave -Excel catalyst 51 open cell traversal operation performance guarantees

In Excel catalyst which launched more than a year, the recurrent heard a voice, probably means that people will actually write the code are not fancy Excel catalyst write functions, making himself a more comfortable intimate, as if VBA can be a little invincible general, seems all the features of Excel catalyst out, in their eyes all the kindergarten level, play house play it.
Not here to comment on this view, speak only facts, and see a little VBA people, can create the following function codes to guarantee superior performance.

Cell performance problems traversal

VBA studied groups, we know that traverse the cell is a very slow process, it is best to put the array and then iterate.

Why would slow this problem may not have studied in depth, and I used his unprofessional language next reason is because such as VBA or VSTO code that interacts with Excel is that communication COM, and this COM Communication is very bloated, traverse process, continue to communicate back and forth, resulting in a very inefficient performance.

The data in the array, that is, into the memory access, and no longer need to communicate frequently and COM interfaces, so you can get up.

In addition to COM interface to access other access methods

For developers VBA, VB is, it can only be visited with the COM interface, no professional programmers to the world they made some nice wheels can be accessed directly xls or xlsx file.

But in the world of VSTO .Net, this needs to be very just, especially the application server level, and then can not cope with COM interfaces to communicate with high concurrency requirements. So there are a lot of good third-party access library wheels in the .Net world more famous and have NPOI EPPLUS.

Because Excel catalyst and in order to meet the needs of all users exists, the use of low version of the still OFFICE2003 version is not supported, so you have a choice, a large number of scenes will be used only to support this EPPLUS OFFICE2007 and above format library wheels.

In general can traverse an array or native search method, but need to find and replace the old data, and the need to use regular expressions to match the scene, with the above two methods is very clumsy.

Cell embodiment traversal EPPLUS

Function as the original source for the following applications: 75th wave - tabbed reporting standard data transfer source https://www.jianshu.com/p/a876134c9e8f

EPPLUS traversal cell on very simple operations and almost directly on the VBA object model (with larger differences would NPOI, so I do not like to use it).

Directly on the code
This code is the 75-wave core code for the searched result is stored as a new table of contents, ultimately returned to the user a structured data source.

 private static void AddMatchDataToDataTable(bool isActWkb, string filePath, DataTable settingTable, ref DataTable resultTable)
        {
            using (var package = new ExcelPackage(new FileInfo(filePath)))
            {
                ExcelWorkbook wkb = package.Workbook;

                foreach (var itemSht in wkb.Worksheets)
                {
                    string itemShtName = itemSht.Name;
                    if (itemShtName != settingShtName && itemShtName != resultShtName)
                    {
                        foreach (var cell in itemSht.Cells)
                        {
                            if (cell.Value != null)
                            {
                                bool isMatch = IsMatchPattern(pattern, matchType, isIgnoreCase, lookin, isRegexMatch, cell);
                                if (isMatch)
                                {
                                    DataRow dr = resultTable.NewRow();
                                    dr["工作薄路径"] = package.File;
                                    dr["工作表名称"] = itemShtName;

                                    int iStart = 2;
                                    foreach (DataRow row in settingTable.Rows)
                                    {
                                        //todo
                                        dr[iStart] = GetCellInfo(cell.Offset(Convert.ToInt32(row[1]), Convert.ToInt32(row[2])));
                                        iStart++;
                                    }
                                    resultTable.Rows.Add(dr);
                                }

                            }
                        }
                    }

                    if (isActWkb)
                    {
                        AddDataToResultSht(resultTable, wkb);
                        package.Save();
                    }// if (isActWkb)
                }//foreach (var itemSht in wkb.Worksheets)
            }

        }

Epilogue

In the world of VSTO, you can call all professional programmers wrote our wheels libraries, relatively VBA developers, there is a natural advantage, the pursuit of the group, it may be another step out of the comfort zone VBA, VSTO hug the development will be a wider sky.

Technical exchange QQ group

QQ group name: Excel catalyst open discussion groups, QQ group number: 788 145 319
Excel catalyst dimensional code open source discussion groups

About Excel catalyst

Excel catalyst name, first a public micro-channel number, then shun its name, officially launched the Excel plug-in, plug-continuous updates, the update cycle depends on my time may be able to fight for one week on a line function modules. Excel catalyst plug-permanent commitment to individual users free of charge!

Excel catalyst plugin uses the latest deployment of technology, once installed, all future updates automatically update is complete, no need to repeat concerns updates, manually download the installation package to reinstall, you can always keep the latest version with a single installation!

The catalyst Excel plug-in download link: https://pan.baidu.com/s/1Iz2_NZJ8v7C9eqhNjdnP3Q

Contact the author

No public

取名催化剂,因Excel本身的强大,并非所有人能够立马享受到,大部分人还是在被Excel软件所虐的阶段,就是头脑里很清晰想达到的效果,而且高手们也已经实现出来,就是自己怎么弄都弄不出来,或者更糟的是还不知道Excel能够做什么而停留在不断地重复、机械、手工地在做着数据,耗费着无数的青春年华岁月。所以催生了是否可以作为一种媒介,让广大的Excel用户们可以瞬间点燃Excel的爆点,无需苦苦地挣扎地没日没夜的技巧学习、高级复杂函数的烧脑,最终走向了从入门到放弃的道路。

最后Excel功能强大,其实还需树立一个观点,不是所有事情都要交给Excel去完成,也不是所有事情Excel都是十分胜任的,外面的世界仍然是一个广阔的世界,Excel只是其中一枚耀眼的明星,还有其他更多同样精彩强大的技术、工具等。*Excel催化剂也将借力这些其他技术,让Excel能够发挥更强大的爆发!

关于Excel催化剂作者

姓名:李伟坚,从事数据分析工作多年(BI方向),一名同样在路上的学习者。
服务过行业:零售特别是鞋服类的零售行业,电商(淘宝、天猫、京东、唯品会)

技术路线从一名普通用户,通过Excel软件的学习,从此走向数据世界,非科班IT专业人士。
历经重重难关,终于在数据的道路上达到技术平原期,学习众多的知识不再太吃力,同时也形成了自己的一套数据解决方案(数据采集、数据加工清洗、数据多维建模、数据报表展示等)。

擅长技术领域:Excel等Office家族软件、VBA&VSTO的二次开发、Sqlserver数据库技术、Sqlserver的商业智能BI技术、Powerbi技术、云服务器布署技术等等。

2018 began his career made a major adjustment, from the original full-time job, turned freelance, no fixed income, temporarily on the road ahead is not clear, bitter return to full-time job, for Excel catalyst operations and development must be greatly affected (within the time could not maintain full-time job can not just put the results in a work published in time, the time outside of work is very limited, because he has thirty years of age, family responsibility).

And the majority of advocates with expectations: Excel catalyst has been able to run down, I have the benefit of the group were able to support ( multi-message encouragement, friend circle under forwarded the recommendation under small a reward and the most focused and where the company can and recommended recommended peers, so I can maximize the value of technology in your company to achieve a win-win (you can imagine how the data is preliminary consultant or small projects to develop forms of cooperation).

Guess you like

Origin www.cnblogs.com/ExcelCuiHuaJi/p/11225167.html