Step 1 - Librerie
- Open XML Format SDK 2.0 - Libreria microsoft con il necessario per creare e gestire file excel.
- ExcelPackage: Office Open XML Format file creation - Sostanzialmente un façade sulla precedente libreria (senza è veramente complesso).
Step 2 - Bug fixies
Sono presenti due problemi principali nella librearia ExcelPackage:- Non è possibile creare documenti su uno stream di dati ma solo su file. Per questo è necessario applicare il seguente fix (che consiste nel ricompilare la libreria e applicare alcune modifiche): Using the ExcelPackage class on a web page
- E' presente un errore nella gestione delle query xpath, non viene fatto l'escape della stringa di ricerca. Grazie a questo post C-Sharp function to escape single-quote on XPath expression ho modificato la funzione
private int SetSharedString(string Value)
...
// Check to see if the string already exists. If so, retrieve its index.
// This search is case-sensitive, but Excel stores differently cased
// strings separately within the string file.
//MODIFIED TO USE ParseXpathString
XmlNode stringNode = _xlWorksheet.xlPackage.Workbook.
SharedStringsXml
.SelectSingleNode(string.Format("//d:si[d:t={0}]",
ParseXpathString(Value)),
_xlWorksheet.NameSpaceManager);
