Excel catalyst 38 open string rotation plurality of wave table structure -json

As a developer, the face of json character that is not strange, but for the average user, more appropriate data structure of the table, the best data has been lying in the Excel spreadsheet without importing and exporting operation everywhere. So between developers and users have different data requirements and the use of thinking.
Cipian bring some new ideas to you, how you can allow users to independently participate in the process to get the data, while reducing development effort but gain customer satisfaction.

IT era intelligence realm income tax eventually will pass

As the author of a non-IT majors in college, knowledge of the IT field is not deep, let's talk about some of their own small opinion.

Ordinary people produced a variety of systems and software for a variety of IT, awesome love-hate relationship. Good system or software, brings a lot of repetitive work efficiency gains, poor systems or software, all day long abused to do some boring data entry and endure all kinds of imperfections.

From an employer point of view, IT systems, software these, it really is easy to pay taxes IQ, pre-hype, as long as the money, the money in place, what functions can be done on the system, the entire company invincible .

Of course fee is generally a high price, most non-IT people are not aware how high the cost, why can sell so expensive.

So from the point of view of the user to be educated, highly intelligent era income tax, will eventually in the past, as now, as the retail market, we will finally trip to rational consumption, shop around, buy only high price right thing, including IT products.

How can I do a cost-effective product?

Seems to digress, back to Cipian json conversion, I understand is: Let the user feel more involved add to the mix, not only to train the user into a fool-style operation, mobilize the user's own level, in particular OFFICE office software skills these abilities, added its own software products in the past.

For users to make a fool of most products, certainly more things to consider, the cost increase is necessary, the versatility of the product has been damaged.

When the user's ability to be mobilized, and ultimately you can achieve similar functionality as Benpian, threw a json string user, the user's own to explain it, select the data content they want, without too much secondary development effort.

Json characters from the data the user wants

json character, the data model can store the entire dataset, wherein the plurality of tables mixed, there is one to one, one-to-many relationship between structure, general users need to intractable.

Therefore, from the user's point of view, certainly we need to interface operation, guide the user to choose the data to which the table (the table data to be completely de-normalization, all the other end of the property sheet information have brought in, user can use right away, without having to manually re-association complex), and then let the user choose to return the data fields required to achieve a fully dynamic, instrumental output lotus solution.

The core implementation process and code

It only to the main piece of code method, can be used for the reference, the following ideas:

  private void ConvertJsonToDataTable()
        {
            var jsonInfo = JsonInfos.FirstOrDefault();

            JObject jObject = JObject.Parse(jsonInfo.JsonString);

            ////拿到要遍历的数组路径,需要有【数字】的结构,query获取到最后一是【数字】的结构
            var paths = jObject.Descendants().Select(s => s.Path).Distinct().ToArray();
            var query = paths.Where(s => Regex.IsMatch(s, @"\[\d+\]"))
                                .Select(t => Regex.Match(t, @".+(?=\[\d+\])").Value)
                                .Distinct().ToArray();

            //再将含数字的数组path去掉数字后分组取第1条,为了减少因多层数组嵌套而引起多条记录,产生多个表的情况。
            var arrPaths = query.GroupBy(s => Regex.Replace(s, @"\[\d+\]", "")).Select(t => t.FirstOrDefault()).ToArray();
            //如果没有数组出现时,就遍历所有后代
            int tableIndex = 0;
            if (arrPaths.Length == 0)
            {
                var mainFieldPathList = paths.Select(s => jObject.SelectToken(s)).Where(t => t is JValue).Select(t => t.Parent.Path).ToList();
                var mainFieldList = mainFieldPathList.Select(s => Regex.Replace(s, @"\[.+?\]", "")).Distinct().ToList();//将字段中的【*】或【0】等都替换为空

                var detailFieldList = new List<string>();
                DataTable dataTable = GetDataTableStructure(mainFieldPathList, detailFieldList);

                AddMainFieldDataToDataRow(jObject, mainFieldPathList, ref dataTable, jsonInfo.AddinalFieldData);

                outputTableInfos.Add(
                                    new OutputTableInfo()
                                    {
                                        HasArrayDetail = false,
                                        ArrJsonPath = "唯一表",
                                        MainFieldPathList = mainFieldPathList,
                                        MainFieldList = mainFieldPathList,
                                        DetailFieldList = detailFieldList,
                                        TableIndex = tableIndex,
                                        OutputTable = dataTable
                                    }
                                );
            }
            else
            {

                foreach (var arrPath in arrPaths)
                {

                    List<string> mainFieldPathList = new List<string>();

                    List<string> mainFieldList = new List<string>();
                    List<string> detailFieldList = new List<string>();

                    var arrItemJoken = jObject.SelectToken(arrPath);
                    //获得它的所有子项,不包含后面还有数组的情况,并且把那些不是叶子级的path也过滤了,
                    //replace是只替换最后一个数字编号,之前的属于其父级的数组不替换,但存放的表的字段时要替换

                    var arrPathEscape = arrPath.Replace("[", @"\[").Replace("]", @"\]").Replace(".", @"\.");
                    var detailDecendantsAll = arrItemJoken.Parent.Descendants().Select(s => s.Path)
                        .Where(r => !Regex.IsMatch(r, arrPathEscape + @"\[\d+\].+\[\d+\]"))
                        .Where(t => Regex.IsMatch(t, arrPathEscape + @"\[\d+\].+")).Distinct().ToList();

                    var detailDecendantsDistinct = detailDecendantsAll.Select(n => Regex.Replace(n, @"(?<=.+)\[\d+\]", "[*]"))
                        .Distinct()
                        .ToList();

                    detailFieldList.AddRange(detailDecendantsDistinct.Select(s => Regex.Replace(s, @"\[.+?\]", "")).Distinct());//将字段中的【*】或【0】等都替换为空

                    mainFieldPathList = GetMainFieldPathList(jObject, arrItemJoken);
                    mainFieldList.AddRange(mainFieldPathList.Select(s => Regex.Replace(s, @"\[.+?\]", "")).Distinct());//将字段中的【*】或【0】等都替换为空

                    DataTable dataTable = GetDataTableStructure(mainFieldList, detailFieldList);

                    AddDetailDataToDataRow(jObject, mainFieldPathList, detailDecendantsAll, detailDecendantsDistinct.Count, ref dataTable, jsonInfo.AddinalFieldData);
                    outputTableInfos.Add(
                                        new OutputTableInfo()
                                        {
                                            HasArrayDetail = true,
                                            MainFieldList = mainFieldPathList,
                                            DetailFieldList = detailFieldList,
                                            ArrJsonPath = arrPath,
                                            TableIndex = tableIndex,
                                            OutputTable = dataTable
                                        });
                    tableIndex++;
                }//foreach (var arrPath in arrPaths)
            }//if (arrPaths.Length == 0)
        }

First, because of the presence of multiple dataset table structure, each node of the array need to do a table to store data, to avoid data return many relationships, cause data errors, duplication and redundancy.

Each Array node to do a table

Second, the sub-node under the recording Array interpreted as the child node still Array structure, this part of the structure will not be explained Array, likewise prevents generation-many data structures.

If it needs to explain the following sub-Array, which is a more detailed of the table relative to its parent fathers who have appeared Array table.

Not for children under poi interpreted array

Third, according to the above Array fathers and the following results corresponding to the object attribute field will be explained, these parts constituting the end of the data field of the details described in this Array node.

Poi ancestor node node has Root, its attributes are explained

Fourth, sibling sibling of Array to explain this, only
Sibling nodes suggestion poi node attribute interpretation

Fifth, experience more of the Array node, the node fathers, siblings siblings dealt with, to deal with their own parallel node data, using a positive message of equality node is carried out are explained.

The children nodes also poi Array class fathers, we need to explain all the childern all poi

final effect

The configuration dataset json string after the above explanation, the structure of a plurality of tables will appear, are many relationship, many relationships do not exist, as shown in the following table, simple interface with the package, so that the user can more relaxed and comfortable to operate.

Table 1, the theme of the district table

Table 2, points of interest topic tables

Table Table 3, the theme of the road

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催化剂插件使用最新的布署技术,实现一次安装,日后所有更新自动更新完成,无需重复关注更新动态,手动下载安装包重新安装,只需一次安装即可随时保持最新版本!

Excel催化剂插件下载链接: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方向),一名同样在路上的学习者。
服务过行业:零售特别是鞋服类的零售行业,电商(淘宝、天猫、京东、唯品会)

Technical route from an ordinary user, through the Excel software to learn, go from the data world, Coban non-IT professionals.
After many difficulties, and finally reach the plains of technical data on the road, learning many knowledge is no longer too difficult, but also formed its own set of data solutions (data collection, data cleaning and processing, multi-dimensional data modeling, data reporting display, etc.).

Specializes in technology areas: Excel and other Office family of software, the secondary development of VBA & VSTO, Sqlserver database technology, business intelligence BI technology Sqlserver of, Powerbi technology, cloud server deployment technologies.

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/11225046.html