private void showFileOpen() { string loadFile = string.Empty; //Microsoft.Office.Core.FileDialog fd = // this.Application.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen); Microsoft.Office.Core.FileDialog fd = this.Application.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogFilePicker); fd.AllowMultiSelect = false; fd.Filters.Clear(); fd.Filters.Add("Text Files", "*.prn;*.txt;*.csv", missing); fd.Filters.Add("All Files", "*.*", missing); if (fd.Show() != 0) { //fd.Execute(); loadFile = fd.SelectedItems.Item(1); // show Import Wizard } }
//--------------------------------------------------------------------- void Test3() { //<Snippet45> Globals.Sheet1.CheckSpelling(); //</Snippet45> //<Snippet32> this.data2001.Group(); //</Snippet32> //<Snippet33> this.Application.get_Range("data2001"); this.Application.get_Range("data2002") .Group(); this.Application.get_Range("dataAll") .Group(); //</Snippet33> //<Snippet34> this.data2001.Ungroup(); this.data2002.Ungroup(); this.dataAll.Ungroup(); //</Snippet34> //<Snippet35> this.Application.get_Range("data2001").Ungroup(); this.Application.get_Range("data2002").Ungroup(); this.Application.get_Range("dataAll").Ungroup(); //</Snippet35> //<Snippet48> Microsoft.Office.Tools.Excel.NamedRange nr = this.Controls.AddNamedRange(this.Range["A1"], "NamedRange1"); nr.Value2 = "Hello World"; //</Snippet48> //<Snippet82> Globals.Sheet1.PrintPreview(); //</Snippet82> //<Snippet81> this.Application.Workbooks.OpenXML(@"C:\Test.xml"); //</Snippet81> //<Snippet80> this.Application.Workbooks.OpenText(@"C:\Test.txt", missing, 3, Excel.XlTextParsingType.xlDelimited, Excel.XlTextQualifier.xlTextQualifierNone, missing, missing, missing, true, missing, missing, missing, missing, missing, missing, missing, missing, missing); //</Snippet80> //<Snippet79> this.fruitList.Range.Sort( this.fruitList.ListColumns[1].Range, Excel.XlSortOrder.xlAscending, this.fruitList.ListColumns[2].Range, missing, Excel.XlSortOrder.xlAscending, missing, Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlYes, missing, missing, Excel.XlSortOrientation.xlSortColumns, Excel.XlSortMethod.xlPinYin, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal); //</Snippet79> //<Snippet78> this.Fruits.Sort( this.Fruits.Columns[1, missing], Excel.XlSortOrder.xlAscending, this.Fruits.Columns[2, missing], missing, Excel.XlSortOrder.xlAscending, missing, Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlNo, missing, missing, Excel.XlSortOrientation.xlSortColumns, Excel.XlSortMethod.xlPinYin, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal); //</Snippet78> //<Snippet77> this.Application.Calculate(); //</Snippet77> //<Snippet75> Microsoft.Office.Tools.Excel.NamedRange NamedRange1 = this.Controls.AddNamedRange(this.get_Range("A1"), "NamedRange1"); //</Snippet75> //<Snippet76> NamedRange1.Calculate(); //</Snippet76> //<Snippet74> Globals.ThisWorkbook.SendMail("*****@*****.**", "July Sales Figures"); //</Snippet74> //<Snippet73> Microsoft.Office.Core.FileDialog fd = this.Application.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen); fd.AllowMultiSelect = true; fd.Filters.Clear(); fd.Filters.Add("Excel Files", "*.xlsx;*.xlw"); fd.Filters.Add("All Files", "*.*"); if (fd.Show() != 0) { fd.Execute(); } //</Snippet73> //<Snippet70> System.Security.Principal.WindowsIdentity user; user = System.Security.Principal.WindowsIdentity.GetCurrent(); //</Snippet70> //<Snippet71> Microsoft.Office.Tools.Excel.NamedRange userID; userID = this.Controls.AddNamedRange(this.Range["A1"], "userID"); userID.Value2 = user.Name; //</Snippet71> //<Snippet67> Excel.Range rng2 = this.Application.get_Range("A1"); rng2.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red); //</Snippet67> //<Snippet65> Microsoft.Office.Tools.Excel.NamedRange rng = this.Controls.AddNamedRange(this.Range["A1"], "NamedRange1"); //</Snippet65> //<Snippet66> rng.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red); //</Snippet66> //<Snippet54> Microsoft.Office.Tools.Excel.NamedRange rangeStyles = this.Controls.AddNamedRange(this.Range["A1"], "rangeStyles"); rangeStyles.Value2 = "'Style Test"; rangeStyles.Style = "NewStyle"; rangeStyles.Columns.AutoFit(); //</Snippet54> //<Snippet53> Excel.Style style = Globals.ThisWorkbook.Styles.Add("NewStyle"); style.Font.Name = "Verdana"; style.Font.Size = 12; style.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red); style.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Gray); style.Interior.Pattern = Excel.XlPattern.xlPatternSolid; //</Snippet53> }