Thursday, July 21, 2011

Reading XLSX format file from C#

The best guide for reading excel file without Excel instance exist here.

Pay attentions! In the final example in the loop ForEach missed validation of  not string values and NULL value cells, threfore change it to:

foreach (XElement cell in cells)
    if (cell.IsEmpty)
    string cellPosition = cell.Attribute("r").Value;
    int index = IndexOfNumber(cellPosition);
    string column = cellPosition.Substring(0, index);
    int row = Convert.ToInt32(cellPosition.Substring(index, cellPosition.Length - index));
    if (cell.HasElements)
        if (cell.Attribute("t") != null && cell.Attribute("t").Value == "s")
            // Shared value
            int valueIndex = Convert.ToInt32(cell.Descendants(ExcelNamespaces.excelNamespace + "v").Single().Value);
            parsedCells.Add(new Cell(column, row, sharedStrings[valueIndex]));
            string value = cell.Descendants(ExcelNamespaces.excelNamespace + "v").Single().Value;
            parsedCells.Add(new Cell(column, row, value));
        parsedCells.Add(new Cell(column, row, ""));

Wednesday, July 20, 2011

Error in SecurityMode = None in WsHttpBinding

Define next attributes in the binding:

        <binding name="wsHttpBindingConfig">
          <security mode ="None"/>
          <reliableSession enabled="true" />


Tuesday, July 19, 2011

WCF error messages - the guide.

Whenever web developers hear the term session, we think of Http Session which is used to store data between multiple HTTP full article click here!

Sunday, July 10, 2011

Could not load file or assembly 'ASSEMBLY_NAME' or one of its dependencies. An attempt was made to load a program with an incorrect format.

The error occurred as transfer from 32-bit to 64-bit platforms. A solution is very easy:

1. Go to "ASSEMBLY_NAME" project in solution
2. Open project properties
3. Open "Build" tab
4. Change "Platform target" to "Any CPU"
5. Compile solutions.