Short solution for short problems

IIS: What triggers recycle of a website in IIS?

A colleague and me where thinking about this, because we were copying files to the root directory of the web site. But no worries, this doesn't trigger a recycle. What does trigger a recycle?

Trigger Immediate Recycle

  • Web.config changes
  • Machine.config changes
  • Global.asax changes
  • Bin directory changes
  • App_Code changes

Get String from Excel with DocumentFormat.OpenXml (v2.5.5631.0)

Getting a value from a cell is very easy with the openxml library. But getting a string value isn't that straight forward. You will have to use the SharedStringTablePart. More info on this here: https://msdn.microsoft.com/en-us/library/office/gg278314.aspx

In this example I want to get the value from cell A2 on a worksheet in the excel called test:

Using doc As SpreadsheetDocument = SpreadsheetDocument.Open(localExcel, False)
 Dim workbookPart As WorkbookPart
workbookPart = doc.WorkbookPart
Dim stringTable = workbookPart.GetPartsOfType(Of SharedStringTablePart).FirstOrDefault()
Dim clientSheet As Sheet = doc.WorkbookPart.Workbook.Descendants(Of Sheet)().Where(Function(s) s.Name.ToString.ToLower = "test").FirstOrDefault
Dim worksheetPart As WorksheetPart = CType(workbookPart.GetPartById(clientSheet.Id),WorksheetPart)
Dim value As String = GetCellValue(stringTable, worksheetPart, "A2")
If Not value = "" Then
clientNumber = value
End If
End Using

Now the GetCellValue will get the string from the sharedStringTable. The index of the string can be found in the theCell.Cellvalue.Text:

Public Function GetCellValue(ByVal stringTable As SharedStringTablePart,ByVal worksheetPart As WorksheetPart,
ByVal addressName As String) As String
Dim value As String = Nothing
 Dim theCell As Cell = worksheetPart.Worksheet.Descendants(Of Cell).Where(Function(c) c.CellReference = addressName).FirstOrDefault
 If theCell IsNot Nothing Then
  If theCell.DataType IsNot Nothing Then
Select Case theCell.DataType.Value
     Case CellValues.SharedString
Dim index = Integer.Parse(theCell.CellValue.Text)
      If stringTable IsNot Nothing Then
       value = stringTable.SharedStringTable.ElementAt(index).InnerText
      End If
Case Else
      value = theCell.InnerText
    End Select
   End If
  End If
  Return value
End Function