Hi,
I have a Visio diagram. It contains some ‘Excel’ . We tried to remove excel personal information (Like Author, CreatedTime, Modified date), document properties pro-grammatically. But the info not removed from the excel.
Input: Dialog - 28 - Copy.zip (58.7 KB)
Output: Dialog - 28 - Copy_20200609180258_out.zip (48.1 KB)
Code:
public void TestVisioBigExcel()
{
string[] files = Directory.GetFiles(@“C:\Temp\visio”, “*.vsdx”);
foreach(string file in files)
{
Diagram diagram = new Diagram(file, LoadFileFormat.VSDX);
int nFile = 1;
foreach(Aspose.Diagram.Page diagramPage in diagram.Pages)
{
foreach(Aspose.Diagram.Shape OLE_Shape in diagramPage.Shapes)
{
if(OLE_Shape.Type == Aspose.Diagram.TypeValue.Foreign)
{
if(OLE_Shape.ForeignData.ForeignType == ForeignType.Object)
{
Stream Ole_stream = new MemoryStream(OLE_Shape.ForeignData.ObjectData);
// Get format of the OLE file object
Aspose.Cells.FileFormatInfo info = Aspose.Cells.FileFormatUtil.DetectFileFormat(Ole_stream);
if(info.LoadFormat == Aspose.Cells.LoadFormat.Xlsx)
{
// Modify an OLE object
Workbook workbook = new Aspose.Cells.Workbook(new > MemoryStream(OLE_Shape.ForeignData.ObjectData));
workbook.BuiltInDocumentProperties.Clear();MemoryStream outStream = new MemoryStream(); workbook.Save(outStream, Aspose.Cells.SaveFormat.Xlsx); OLE_Shape.ForeignData.ObjectData = outStream.ToArray(); nFile++; // Save back an OLE object } } } } } // Save Visio diagram diagram.Save($"C:\\Temp\\visio\\out{DateTime.Now.ToString("yyyyMMddHHmmss")}.vsdx", SaveFileFormat.VSDX); } }
Reference: image.png (266.0 KB)
Expected Output : image.png (242.5 KB)
Waiting for your support and reply.
Thanks