Thursday, June 6, 2013

Office Open XML cell.StyleIndex OR how to set style of your cell using OpenXML

Have you ever tried to set style of a cell of your Excel document? If not, then trust me, it is not an easy task :)
Even changing background colour of a cell is becoming whole challenge in OpenXML. The only thing which you can  do is to set  cell.StyleIndex in your code. What value must be assigned to this property is a big story. For interest you can read some information and ways to do this in http://bloggingmath.wordpress.com/2010/07/21/setting-a-cell-color-with-open-xml-spreadsheetml/ and http://msdn.microsoft.com/en-us/library/hh180830%28v=office.14%29.aspx. The way, which I am proposing is much easer compared the ones ,which you will find in google and big.

Here are the steps to set custom style to your cell.

1. Create excel document, which you will use as a template in your code. You will need it anyway.
2. Create new excel sheet in your document and set it`s style to the one, you want. In the image above this cell is B4.
3. Get the style index of this cell and assign it to the cell, which style you want to change. 
The code will be something similar this:
 
//Retrieve style index  
cell = GetCell(worksheetPart.Worksheet, "B", 4);
UInt32Value styleIndex = cell.StyleIndex;
//Set style index to other cell
cell = GetCell(worksheetPart.Worksheet, "A", 12);
cell.CellValue = new CellValue("Управление проектом");
cell.DataType = new EnumValue<CellValues>(CellValues.String);
cell.StyleIndex = styleIndex;
4. That is it. You solved the challenge by writing few lines of code.
You can also hide sheet 2 in you template excel document, so clients will not see it in the generated document.

Wednesday, April 17, 2013

Importing organisation in MS CRM 4,0

Task: Import organisation with existing database to CRM 4.
Solution: The solution is obvious - restore existing database in SQL Server and then import organisation via Deployment Manager. Also there are a lot of articles, which can help you accomplish this task. One of them is http://www.tribridge.com/Blog/crm/default/2011-06-14/How-to-Migrate-CRM-4-SQL-2005-32-bit-to-SQL-2008-64-bit-Environment.aspx.

Tuesday, March 26, 2013

SharePoint 2013: RelatedItems column in WebPart

Task: Show related items in the web part like the image bellow:

Resolution:

CRM 4: Create custom button in associated list view menu

Have you ever tried to remove "Add existing button" or add your new custom button to associated list view menu like the image bellow?

Ok, by few lines of JS you can do this. Here is how:

Friday, March 22, 2013

SharePoint 2013: Approve and Reject buttons on DispForm.aspx of task

Task: Create custom view form, which will contain 2 buttons allowing to accept and reject task  (Set TaskOutcome field) in view mode.
Something like this:

Monday, December 17, 2012

Steps you need to check when hosting Silverlight on IIS 6

When you are hosting a Silverlight application on ISS, you need at first check the following things:
1. .svc file type is mapped to the aspnet_isapi.dll. If it is not, then you`ll see the following screen, when opening your .svc in web browser:

Friday, December 14, 2012

Host Silverlight Application on IIS 6

When hosting silverlight application on IIS6 you can get the following error message: