简体   繁体   中英

Refresh slide master view

I'm updating the data of a table on powerpoint 2010 slide (msotable type of shape) from a database. I'm using chart.Refresh to refresh successfully the slide master containing the charts (msochart). I want to do the same for tables types of shapes. But there is no refresh method for tables and my slide master view stays not refreshed (updated) after the successfull update on main slide view. I'm using C# 4.0 interop for office 2010.
Any idea how to refresh table slide master view? http://office.microsoft.com/en-001/powerpoint-help/what-is-a-slide-master-HA010280572.aspx

Found a solution. When there is no method for refresh, I do a hack: sh.Width = sh.Width + 1; sh.Width = sh.Width - 1;

   public void UpdateTable(Shape sh, System.Data.DataTable dt)
    {
        try
        {
            //Supprimer toutes les lignes existantes
            if (sh.Table.Rows.Count >= 3)
            {
                int rowCount = sh.Table.Rows.Count;
                for (int i = 3; i <= rowCount; i++)
                {
                    sh.Table.Rows[sh.Table.Rows.Count].Delete();
                }

                //Vider le contenu de la première ligne
                for (int j = 1; j < sh.Table.Columns.Count; j++)
                {
                    sh.Table.Cell(2, j).Shape.TextFrame.TextRange.Text = "";
                }
            }

            //Parcourir les lignes
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sh.Table.Rows.Add(sh.Table.Rows.Count);
                //Parcourir les colonnes
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    sh.Table.Cell(i + 2, j + 1).Shape.TextFrame.TextRange.Text = dt.Rows[i][j].ToString();
                }
            }
            sh.Table.Rows[sh.Table.Rows.Count].Delete();

            sh.Width = sh.Width + 1;
            sh.Width = sh.Width - 1;

            Marshal.ReleaseComObject(sh);
        }
        catch (Exception exp)
        {
            Logger.Error(exp);
        }

    } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM