Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Created Issue: Corrupted file when both VBA and Pivots are used [14797]

$
0
0
Whenever I put both a pivot table and a VBA project in the same file (such as by loading Sample12 file in Sample15 and then continuing as usual) Excel (version 2010) says that it has found unreadable content and then after trying to recover it, it shows another message 'Removed Feature: PivotTable report from /xl/pivotTables/pivotTable1.xml part (PivotTable view)'

private static void VBASample1(DirectoryInfo outputDir)
{
string file = outputDir.FullName + @"\sample12.xlsx";

FileStream fs = new FileStream(file, FileMode.Open);

using (ExcelPackage pck = new ExcelPackage(fs))
{
//ExcelPackage pck = new ExcelPackage();

//Add a worksheet.
var ws = pck.Workbook.Worksheets.Add("VBA Sample");
ws.Drawings.AddShape("VBASampleRect", eShapeStyle.RoundRect);

//Create a vba project
pck.Workbook.CreateVBAProject();

//Now add some code to update the text of the shape...
var sb = new StringBuilder();

sb.AppendLine("Private Sub Workbook_Open()");
sb.AppendLine(
" [VBA Sample].Shapes(\"VBASampleRect\").TextEffect.Text = \"This text is set from VBA!\"");
sb.AppendLine("End Sub");
pck.Workbook.CodeModule.Code = sb.ToString();

//And Save as xlsm
pck.SaveAs(new FileInfo(outputDir.FullName + @"\sample15-1.xlsm"));
}
}

Viewing all articles
Browse latest Browse all 2262

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>