2010-04-11 5 views

Répondre

2

Vous pouvez définir IRange.NumberFormat sur ";;;" pour que le contenu d'une cellule soit caché. Il y a aussi IRange.FormulaHidden, IRange.Rows.Hidden, IRange.Columns.Hidden et probablement d'autres façons d'aborder ce que je ne pense pas. Voici un code qui démontre ces approches:

namespace Program 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      // Create a new workbook and get a reference to Sheet1!A1. 
      var workbook = SpreadsheetGear.Factory.GetWorkbook(); 
      var sheet1 = workbook.Worksheets[0]; 
      var a1 = workbook.Worksheets[0].Cells["A1"]; 
      // Put some text in A1. 
      a1.Value = "Hello World!"; 
      // Set a number format which causes nothing to be displayed. 
      // 
      // This is probably the best way to hide the contents of 
      // a single cell. 
      a1.NumberFormat = ";;;"; 
      // Set FormulaHidden to true - must set IWorksheet.ProtectContents 
      // to true for this make any difference. This will not hide values 
      // in cells. 
      a1.FormulaHidden = true; 
      // Hide the row containing A1. 
      a1.Rows.Hidden = true; 
      // Hide the column containing A1. 
      a1.Columns.Hidden = true; 
     } 
    } 
} 
+1

Hey Joe Merci de donner soupçon, je me suis solution de mon problème avec indice donné dans votre code, je l'ai déjà été en utilisant a1.NumberFormat = « ;;; " mais il ne servait pas mes besoins, il était caché contient des cellules mais, les cellules contiennent ware visible dans la barre de formule, maintenant j'utilise a1.NumberFormat = ";;;" et a1.FormulaHidden = true à la fois et cela fonctionne bien pour mes besoins. – Avinash

Questions connexes