Writing Data From .Net to Excel Interrupted by User Opening Excel Window

Problem I have an application that generates financial reports in excel. After installing Office 2013, if a user opens excel while the application is running, the application returns a error: System.Runtime.InteropServices.COMException with HRESULT: 0x800AC472 which interrupts the data from being written to the spreadsheet. After some research according to Microsoft this was done by design, the … More Writing Data From .Net to Excel Interrupted by User Opening Excel Window

Handy C#, VB.Net & SQL Code Snippets

Date time – how to initialize a date [code language=”csharp”] DateTime value = new DateTime(2017, 1, 18); [/code] Concatenate string list into comma separated string [code language=”csharp”] List<string> message = new List<string>(); message.Add("Record exists"); message.Add("Invalid data format"); message.Add("Duplicated record"); string output = String.Join(", ", message.Where( m=> (m.Length != 0))); Console.WriteLine(output); [/code] Initialize a string list … More Handy C#, VB.Net & SQL Code Snippets

Refactoring III -Why is this here?

On the previous post I moved URL parsing code by extending the StockData class and creating a property called Url, now we are left with this code, but if you look at the highlighted code, there are way too many things happening here!. [code language=”csharp” highlight=”14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29″] private void btnStockSales_Click(object sender, RoutedEventArgs e) { TickerDataCollection = new ObservableCollection(); // … More Refactoring III -Why is this here?

Sum and Group Data Table Records Using Linq

The Problem You have a data table and you need to group and sum records dynamically. Solution I needed to group information by a field and the sum the values on a different field; For example, I want to group employees by department and then sum their salary. Below is the linq code to this: … More Sum and Group Data Table Records Using Linq