Excel catalyst 49th wave -Excel open source and PowerBIDeskTop interconnection of Part III

In PowerBIDeskTop open SSAS service, and a difference between the nature of Sqlserver is opened by the former its port number is randomly generated, that is, the last open port number obtained, the next time off and back on, the system assigns it to a new port number, and the latter because it is the server version, SSAS server port number is fixed, and the server are generally long-term open, change the port number does not exist data connection string to cause the situation to change.

Cipian corresponding functions implemented by: Wave 3 - (connection PowerbiDesktop Excel pivot table data model) and PowerbiDesktop interconnection https://www.jianshu.com/p/e05460ad407d

Excel connection PowerBIDeskTop port number changed how do?

Because after this problem, you must re-update in Excel on its port number, we can ensure that open PowerBIDeskTop the SSAS service again, the original connection string is stored in the Excel reference data and the results can still maintain SSAS model has connected relationship.

So there have been updating the functional requirements of the connection string, of course, reduce the user's operation as much as possible, so more friendly interface to guide the user to make the necessary recognition to re-match.

Excel and PowerBIDeskTop connected, is connected to undertake a workbook, so only connection traversal workbook, to show it to the user.

        private void formPbidUpdateConnect_Load(object sender, EventArgs e)
        {
            foreach (Excel.WorkbookConnection wkbCnn in Common.ExcelApp.ActiveWorkbook.Connections)
            {
                if (wkbCnn.Description == "pbidConnection")
                {
                    int rowIndex = this.dataGridView1.Rows.Add();
                    this.dataGridView1.Rows[rowIndex].Cells[0].Value = wkbCnn.Name;
                }
            }
            this.fileName.Width = this.workbookConnect.Width + 50;
            this.Width = this.fileName.Width * 2 + 80;

            pbidPortTittleMappings = PbidConnection.GetPbidPortTittleMappings();
            this.fileName.Items.AddRange(pbidPortTittleMappings.Select(s => s.FileName + "|" + s.Port).ToArray());
        }

The final Excel workbook connection, regular expressions, the original port number to replace what you can just use the next.

        private void btnEnter_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                if (row.Cells[1].Value!=null)
                {
                    Excel.WorkbookConnection wkbCnn = Common.ExcelApp.ActiveWorkbook.Connections[row.Cells[0].Value];
                    int newport = int.Parse(row.Cells[1].Value.ToString().Split(new char[] { '|' })[1]);
                    string newDbName = pbidPortTittleMappings.Where(s => s.Port == newport)
                                                        .Select(t => t.DbName).FirstOrDefault();
                    string newModelName = pbidPortTittleMappings.Where(s => s.Port == newport)
                                                        .Select(t => t.ModelName).FirstOrDefault();
                    string wkbcnnString = wkbCnn.OLEDBConnection.Connection;
                    wkbcnnString = Regex.Replace(wkbcnnString, @"(?<=localhost:)\d+", newport.ToString());
                    wkbcnnString = Regex.Replace(wkbcnnString, @"(?<=Initial Catalog=)[^;]+", newDbName);
                    wkbCnn.OLEDBConnection.Connection = wkbcnnString;
                    wkbCnn.OLEDBConnection.CommandText = newModelName;
                }

            }
            this.Close();
        }

Epilogue

In, .Net programming knowledge integration of the three Excel, PowerBIDeskTop, build out the most exciting features of Excel catalyst applications, from the hands of the people, and all of selfless dedication to the community in terms of function realization PowerBI or source code, supply community prosperity.

If you are affected by moving, where endless power of their own micro-Bo, to join the ranks of sharing Excel catalyst them?

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

Named catalyst , due to strong itself, not everyone can immediately enjoy Excel, most people are still at the stage of the child's Excel software, the mind is very clear and want to achieve results, and experts who also have achieved it, that is, how to get yourself out Dounong, or worse, you do not know what Excel can do while staying in constant repetition, mechanically, manually doing data, spend countless youth years. So spawned whether as a medium, so that the majority of Excel users can instantly ignite the explosion point Excel, without the need desperately struggled day and night to learn skills, brain burn senior complex functions, going on from entry to give up the road.

Finally, Excel is powerful, in fact, the need to establish a point of view, not all things have to Excel to complete, and not all things Excel are very competent, the outside world is still a vast world, just a dazzling Excel star, there are other more exciting same powerful technology tools. * Excel catalyst will be leveraging these other technologies, so that Excel can play a more powerful eruption!

About Excel catalyst Author

Name: Li Weijian, for many years engaged in data (BI direction) analysis, a learner in the same way.
Served industries: retail category in particular shoes retail industry, electricity providers (Taobao, Lynx, Jingdong, the only product)

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