Quantcast
Channel: Visio General Questions and Answers for IT Professionals forum
Viewing all articles
Browse latest Browse all 2333

Draw an visio shape as an .vdx file and render the same in a IE browser

$
0
0

I had generated an Visio Diagrams getting input from the excel file and stored it in an local path.

private void DynamicVisio_Load(object sender, EventArgs e)
        {
                       
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'c:\\Test\\FullData3.xls';Extended Properties='Excel 8.0;HDR=Yes;'";

            string sQuery = "select * from [Customer1_Server$] order by Name";

            DataSet objExcelDS = new DataSet();
            OleDbDataAdapter objDA = new OleDbDataAdapter(sQuery, strConn);
            objDA.Fill(objExcelDS);
           
            double dblX1 = 0.5d;
            double dblY1 = 10.3d;
            double dblX2 = 2.258d;
            double dblY2 = 6.8d;

            String sText = "";
            String sFilePath = "";
            String sDisk = "";
            String[] sArray;
            String[] separators = { "," };
            String sPicturePath = "C:\\Test\\test.png";
            String sIPRangeValue = "";
            Visio.Application objVApp = new Microsoft.Office.Interop.Visio.Application();

            objVApp.Documents.Add(@"C:\Test\CustomTemplate\ServerTemplate.vsd");// add a document
               
            for (int i = 0; i < objExcelDS.Tables[0].Rows.Count; i++)
            {

                Visio.Page objVAPage = objVApp.ActiveDocument.Pages.Add();
                objVApp.Documents.Add(@"C:\Test\CustomShapes\MyShapes.vss");// add a document
                               
                Visio.Document objVADoc = objVApp.ActiveDocument;// set the working  document to our new document

                Visio.Masters objVMasters = objVADoc.Masters;

                Visio.Master objVMaster = objVMasters.get_ItemU("CustomTab");
                Visio.Shape objTabShape = objVAPage.Drop(objVMaster, 8.24d, 5.54d);

                objTabShape.Text = objExcelDS.Tables[0].Rows[0]["VLAN"].ToString(); ;
                //set the Shape Width
                objTabShape.get_CellsSRC(
                        (short)Microsoft.Office.Interop.Visio.VisSectionIndices.
                        visSectionObject,
                        (short)Microsoft.Office.Interop.Visio.VisRowIndices.
                        visRowXFormIn,
                        (short)Microsoft.Office.Interop.Visio.VisCellIndices.
                        visXFormWidth).ResultIU = 16.0;

                //set the shape height
                objTabShape.get_CellsSRC(
                   (short)Microsoft.Office.Interop.Visio.VisSectionIndices.
                   visSectionObject,
                   (short)Microsoft.Office.Interop.Visio.VisRowIndices.
                   visRowXFormIn,
                   (short)Microsoft.Office.Interop.Visio.VisCellIndices.
                   visXFormHeight).ResultIU = 10.6;

           
                Visio.Shape objOuterBox = objVAPage.DrawRectangle(dblX1, dblY1, dblX2, dblY2); // Outer Rectange

                sFilePath = "C:\\Temp\\ServerTemplate"+i.ToString()+".vsd";
                objVApp.ActiveDocument.SaveAsEx(@sFilePath, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visSaveAsWS);
            }
        }

but I need to generate the same visio diagram over the web application using the Response.ContentType. ie.

context.Response.ContentType = "application/vdx.visio";

context.Response.AddHeader("content-disposition", String.Format("attachment;filename=\"{0}.vdx\"", fileName));

Pls give me an idea about it along with any example if possible.

Thank you.


Viewing all articles
Browse latest Browse all 2333

Trending Articles



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