private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                tabMetadataTypes.TabPages.Clear();

                DataSet ds;

                using (StreamReader streamReader = new StreamReader(openFileDialog.FileName))
                {
                    try
                    {
                        ds = ExportFacade.ExportToDataSet(streamReader.BaseStream);
                    }
                    catch (GroupDocs.Metadata.Exceptions.InvalidFormatException)
                    {
                        MessageBox.Show(@"This format is not supported");
                        return;
                    }
                    catch (GroupDocs.Metadata.Exceptions.GroupDocsException ex)
                    {
                        MessageBox.Show(string.Format("Error: {0}", ex.Message));
                        return;
                    }
                }

                propertiesEditor      = null;
                saveMetadata.FileName = openFileDialog.FileName;

                if (ds.Tables.Count == 0)
                {
                    MessageBox.Show(@"Metadata not found");
                }
                else
                {
                    for (int i = 0; i < ds.Tables.Count; i++)
                    {
                        DataTable table = ds.Tables[i];

                        Control child;
                        string  tabName;

                        switch (table.TableName.ToLower())
                        {
                        case "xmp":
                            tabName = "XMP metadata";
                            XmpPacketWrapper xmpPacket = MetadataUtility.ExtractXmpPackage(openFileDialog.FileName);
                            ucXmpTree        xmpTree   = new ucXmpTree();
                            xmpTree.LoadControl(xmpPacket);
                            ResizeControl(xmpTree);
                            child = xmpTree;
                            break;

                        case "pdf":
                        case "doc":
                        case "xls":
                        case "ppt":
                            tabName = "Document properties";
                            MetadataPropertyCollection properties = MetadataUtility.ExtractDocumentProperties(openFileDialog.FileName);
                            propertiesEditor = new ucPropertiesEditor();
                            ResizeControl(propertiesEditor);
                            propertiesEditor.LoadControl(properties);
                            child = propertiesEditor;
                            break;

                        default:
                            tabName = string.Format("{0} metadata", table.TableName);
                            DataGridView gridView = new DataGridView();
                            ResizeControl(gridView);
                            gridView.DataSource = table;
                            child = gridView;
                            break;
                        }

                        tabMetadataTypes.TabPages.Add(tabName);
                        TabPage addedTab = tabMetadataTypes.TabPages[i];

                        //addedTab.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top;
                        addedTab.Controls.Add(child);
                    }

                    tabMetadataTypes.Visible = true;
                }
            }
        }
        /// <summary>
        /// Exports metadata of specified file into specified type
        /// </summary>
        public static void ExportMetadata(string filePath, int exportType)
        {
            try
            {
                //ExStart:ExportMetadataAPI
                filePath = Common.MapSourceFilePath(filePath);

                if (exportType == ExportTypes.ToExcel)
                {
                    //ExStart:ExportMetadataToExcel
                    // path to the output file
                    string outputPath = Common.MapDestinationFilePath("metadata.xlsx");

                    // export to excel
                    byte[] content = ExportFacade.ExportToExcel(filePath);

                    // write data to the file
                    File.WriteAllBytes(outputPath, content);
                    //ExEnd:ExportMetadataToExcel
                }
                else if (exportType == ExportTypes.ToCSV)
                {
                    //ExStart:ExportMetadataToCVS
                    // path to the output file
                    string outputPath = Common.MapDestinationFilePath("metadata.csv");

                    // export to csv
                    byte[] content = ExportFacade.ExportToCsv(filePath);

                    // write data to the file
                    File.WriteAllBytes(outputPath, content);
                    //ExEnd:ExportMetadataToCVS
                }
                else
                {
                    //ExStart:ExportMetadataToDataSet
                    // export to DataSet
                    DataSet ds = ExportFacade.ExportToDataSet(filePath);
                    // get first table
                    DataTable products = ds.Tables[0];

                    // need to System.Data.DataSetExtension reference
                    IEnumerable <DataRow> query =
                        from product in products.AsEnumerable()
                        select product;

                    Console.WriteLine("Properties:");
                    foreach (DataRow p in query)
                    {
                        Console.Write(p.Field <string>("Metadata property"));
                        Console.Write(": ");
                        Console.WriteLine(p.Field <string>("Value"));
                    }
                    //ExEnd:ExportMetadataToDataSet
                }
                //ExEnd:ExportMetadataAPI
            }
            catch (Exception exp)
            {
                Console.WriteLine("Exception occurred: " + exp.Message);
            }
        }