internal static byte[] CreateExcel()
{
string text = File.ReadAllText("SampleData\\sharedStrings.xml");
text = text.Replace("SPDGTitle", SampleData.GetSampleValueRandom(SampleData.BusinessDocsTypes));
text = text.Replace("SPDGDate", "Date: " + SampleData.GetRandomDate(1990, 2015).ToShortDateString());
text = text.Replace("SPDGAuthor", "Author: " + SampleData.GetSampleValueRandom(SampleData.FirstNames) + " " + SampleData.GetSampleValueRandom(SampleData.LastNames));
text = text.Replace("SPDGIdentity", "ID: " + SampleData.GetRandomNumber(100000, 1000000).ToString());
File.WriteAllText("SampleData\\SampleExcel\\xl\\sharedStrings.xml", text);
string path = "SampleData\\SampleExcel";
using (ZipFile zip = new ZipFile())
{
zip.AddFile(path + "\\[Content_Types].xml", string.Empty);
zip.AddFile(path + "\\_rels\\.rels", "_rels");
zip.AddFile(path + "\\docProps\\app.xml", "docProps");
zip.AddFile(path + "\\docProps\\core.xml", "docProps");
zip.AddFile(path + "\\xl\\_rels\\workbook.xml.rels", "xl\\_rels");
zip.AddFile(path + "\\xl\\printerSettings\\printerSettings1.bin", "xl\\printerSettings");
zip.AddFile(path + "\\xl\\theme\\theme1.xml", "xl\\theme");
zip.AddFile(path + "\\xl\\worksheets\\_rels\\sheet1.xml.rels", "xl\\worksheets\\_rels");
zip.AddFile(path + "\\xl\\worksheets\\sheet1.xml", "xl\\worksheets");
zip.AddFile(path + "\\xl\\calcChain.xml", "xl");
zip.AddFile(path + "\\xl\\sharedStrings.xml", "xl");
zip.AddFile(path + "\\xl\\styles.xml", "xl");
zip.AddFile(path + "\\xl\\workbook.xml", "xl");
zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");
MemoryStream stream = new MemoryStream();
zip.Save(stream);
byte[] bytes = new byte[stream.Length];
bytes = stream.ToArray();
stream.Close();
return bytes;
}
}