![]() |
fails tospecify max Columns size in 2007, InteropServices.COMExcep
hello , does any one have this problem?
In Excel , the exception throw above system.Runtime.InteropServices.COMException (0x80020005): Type mismatch. see http://forums.microsoft.com/MSDN/Sho...98970&SiteID=1 this threat have been took care for office 2003 system. it is adolutely working fine with using namedRange.inner object in office 2003.. but it have been a issue in office 2007 system. see this code above , there is adsulotely work fine for office 2003. but not office 2k7 : when we migrating a previous Excel xls project 2003 to office 2007, OS XP, using Vsto 2005 SE , use by C#, we change out some of line of code in the template's com library cs, for comptible to office 2007 system , as such Office 2007 ha,ve change column cell maximun limited to 256(IV) to 160000 in the scope of ClearALL this method is to clealr of the all data the have in the column/cell in the sheet.: it is fails to specific the sheet. column object with column's max size -- in sheet .Column range from (AA:ZZ) to (A:IV) ( note column speficfiy in 2003 are fine column(aa:zz) it is exeatly a problem with column 's maximun size to be specify in the code. if you put in 'column(aa:ZZ) in office 2007 , it have 'an invilated range' error throw. cAll= (Excel.Range)this.Sheet.Columns[ "A:IV", Type.Missing ]; b/c office 2007 is change sheet .columns maximun volumn specifiyed to IV. then the column cell is not creating in design time of the project runing , there is a exception throw : system.Runtime.InteropServices.COMException (0x80020005): Type mismatch. we not yet know how to .. have any one got that ? any suggetion? you help are highly appreciated. Chan thanks pinky code exmaple: /// Set individual cell in a workspace into the value /// </summary void SetValue( int r, int c, string s, bool bBold ) { if( s!= "" ) ((Excel.Range)this.Sheet.Cells[r, c ]).FormulaR1C1= s; ((Excel.Range)this.Sheet.Cells[r, c ]).Font.Bold= bBold; } /// <summary /// Set individual cell in a workspace into the value /// </summary string GetValue( int r, int c ) { return ((Excel.Range)this.Sheet.Cells[r, c ]).Value2.ToString(); } /// <summary /// Assign a range with the bold /// </summary void SetBold( int r, int r1, bool b ) { ((Excel.Range)this.Sheet.get_Range( this.Sheet.Cells[r,1], this.Sheet.Cells[r1+1,1] )).Font.Bold= b; ------------------- void ClearAll() { int i= YOFFS; Excel.Range cAll= (Excel.Range)this.Sheet.Rows[ i.ToString()+ ":65535", Type.Missing ]; try { cAll.Rows.Ungroup(); cAll.Rows.Ungroup(); cAll.Rows.Ungroup(); } catch { } cAll.ClearContents(); cAll.Interior.ColorIndex= Excel.XlColorIndex.xlColorIndexNone; cAll.Font.Bold= false; cAll.Locked= true; cAll= (Excel.Range)this.Sheet.Columns[ "A:IV", Type.Missing ]; try { cAll.Columns.Ungroup(); cAll.Columns.Ungroup(); cAll.Columns.Ungroup(); } catch {} this.Sheet.Application.ActiveWindow.FreezePanes= false; // Change default groupping behavior this.Sheet.Outline.AutomaticStyles= false; this.Sheet.Outline.SummaryRow= Excel.XlSummaryRow.xlSummaryAbove; this.Sheet.Outline.SummaryColumn= Excel.XlSummaryColumn.xlSummaryOnRight; } // ---------------------------------------------------------------------------Â*--- /// <summary /// Put all the bases into the worksheet and update the dropdown /// </summary protected void UpdateBase() {//Added the try catch block to capture if any error occurs while displaying the splash screen - Sreejesh try { DataSet cDs= this.cService.GetBaseProducts(this.App.UserName, this.DMP_APP_NAME, DMP_MAIN_FORM ); int x= 1; // Put bases data into the worksheet //MessageBox.Show( "Before Foreach" ); //Sreejesh foreach( DataRow r in cDs.Tables[0].Rows ) { ((Excel.Range)this.Sheet.Cells[ x, 1 ]).Value2= r[1]; ((Excel.Range)this.Sheet.Cells[ x++, 2 ]).Value2= r[0]; } //MessageBox.Show( "After foreach" ); //Sreejesh // Create dropdown Excel.Validation cVal= ((Excel.Range)this.Sheet.Cells[YOFFS - 2, 2]).Validation; cVal.Delete(); string s= "=A1:A" + (x-1).ToString(); //MessageBox.Show( "aFTER Cval" ); //Sreejesh cVal.Add( Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Excel.XlFormatConditionOperator.xlBetween, s, "" ); cVal.IgnoreBlank = false; cVal.InCellDropdown = true; cVal.InputTitle = ""; cVal.ErrorTitle = ""; cVal.InputMessage = ""; cVal.ErrorMessage = ""; cVal.ShowInput = true; cVal.ShowError = true; } catch(Exception e) { throw e; } } // ---------------------------------------------------------------------------Â*--- |
All times are GMT +1. The time now is 04:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com