Currently I am trying to unzip the pptx file with the help of SharpZipLib dll. And trying to unzip the Excel sheet of PPTX file and modifying the concerned xml files (excel) with the input data.
Finally I am zipping the entire pptx and saving the file to my location. When trying to open the file, error has been generated, saying files are corrupted.
Please view the sample Pseudo code
Here TemplateResources.OpenXmlPPT is a PPTX file which resides in .resx,Which acts as a template
ZipOutputStream(file): - file is a SaveDilaog stream object
using (ZipOutputStream outputFile = new ZipOutputStream(file))
{
using (MemoryStream templateBuffer = new MemoryStream((TemplateResources.OpenXmlPPT)))
{
using (ZipInputStream templateFile = new ipInputStream(templateBuffer))
{
while ((ZipEntry entry = templateFile.GetNextEntry()) != null)
{
if (String.Equals(entry.Name,"ppt/embeddings/Microsoft_Office_Excel_Worksheet1.xlsx", StringComparison.OrdinalIgnoreCase))
{
Here is the code for Unzip the xlsx sheet and modify the Conerned Xmls
if (String.Equals(Zpentry.Name, "xl/sharedStrings.xml", StringComparison.OrdinalIgnoreCase))
{
outputFile.Write(“”,””,"”);
}
}
}
}
}
}
I have noticed that modified xml are not updated into exceel sheet with the help of ZipOutputStream . it couldn’t write those things into the exact loaction of the buffer.
Please help in this regard.