I have an excel string (which I built) in memory; the code looks something like this:
public static void exportToExcel()
{
const string startExcelXML = "<xml version>\r\n<Workbook " +
"xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n"
+
" xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n " +
"xmlns:x=\"urn:schemas- microsoft-com:office:" +
"excel\"\r\n xmlns:ss=\"urn:schemas-microsoft-com:"
+
"office:spreadsheet\">\r\n <Styles>\r\n " +
"<Style ss:ID=\"Default\" ss:Name=\"Normal\">\r\n " +
"<Alignment ss:Vertical=\"Bottom\"/>\r\n <Borders/>" +
"\r\n <Font/>\r\n <Interior/>\r\n <NumberFormat/>" +
"\r\n <Protection/>\r\n </Style>\r\n " +
"<Style ss:ID=\"BoldColumn\">\r\n <Font " +
"x:Family=\"Swiss\" ss:Bold=\"1\"/>\r\n </Style>\r\n " +
"<Style ss:ID=\"StringLiteral\">\r\n <NumberFormat" +
" ss:Format=\"@\"/>\r\n </Style>\r\n <Style " +
"ss:ID=\"Decimal\">\r\n <NumberFormat/>\r\n </Style>\r\n " +
"<Style ss:ID=\"Integer\">\r\n <NumberFormat "
+
"ss:Format=\"0\"/>\r\n </Style>\r\n <Style " +
"ss:ID=\"DateLiteral\">\r\n <NumberFormat " +
"ss:Format=\"dd/mm/yyyy;@\"/>\r\n </Style>\r\n " +
"</Styles>\r\n ";
const string endExcelXML = "</Workbook>";
int sheetCount = 1;
StringBuilder sb = new StringBuilder();
sb.Append(startExcelXML);
sb.Append("<Worksheet ss:Name=\"Sheet" + sheetCount + "\">");
sb.Append("<Table>");
sb.Append("<Row>");
sb.Append("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
sb.Append("Home country");
sb.Append("</Data></Cell>");
sb.Append("<Cell ss:StyleID=\"BoldColumn\"><Data ss:Type=\"String\">");
sb.Append("Expatriation Type");
sb.Append("</Data></Cell>");
sb.Append("</Row>");
sb.Append("<Row>");
sb.Append("<Cell ss:StyleID=\"StringLiteral\">" +
"<Data ss:Type=\"String\">");
sb.Append("Singapore");
sb.Append("</Data></Cell>");
sb.Append("<Cell ss:StyleID=\"StringLiteral\">" +
"<Data ss:Type=\"String\">");
sb.Append("Benchmark");
sb.Append("</Data></Cell>");
sb.Append("</Row>");
sb.Append("</Table>");
sb.Append(" </Worksheet>");
sb.Append(endExcelXML);
}
I able to open the file as excel sheet only if I save the file physically; but is there any other way to just open the xml string from the memory as excel sheet?