[]
        
(Showing Draft Content)

PasteOption

Class PasteOption

java.lang.Object
com.grapecity.documents.excel.PasteOption

public class PasteOption extends Object
Represents options that control how a copied range is pasted.

Use this class with IRange.copy(IRange,PasteOption) to specify whether hidden cells are included in the paste operation and which PasteType values are pasted. A new instance allows pasting hidden ranges by default, and its default paste type includes formulas and formats.


 worksheet.getRange("A1:B3").setValue(new Object[][] {
     {"Name", "Value"},
     {"Alice", 100},
     {"Bob", 200}
 });
 worksheet.getRange("2:2").setHidden(true);

 PasteOption option = new PasteOption();
 option.setAllowPasteHiddenRange(false);
 worksheet.getRange("A1:B3").copy(worksheet.getRange("D10"), option);
 
  • Constructor Details

    • PasteOption

      public PasteOption()
  • Method Details

    • getAllowPasteHiddenRange

      public boolean getAllowPasteHiddenRange()
      Gets whether hidden cells in the copied range are included in the paste operation.

      Use this property with IRange.copy(IRange,PasteOption) to determine whether content from hidden rows or columns is pasted. A new PasteOption instance allows pasting hidden ranges by default.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"Alice", 100},
           {"Bob", 200}
       });
       worksheet.getRange("2:2").setHidden(true);
      
       PasteOption option = new PasteOption();
       option.setAllowPasteHiddenRange(false);
       boolean allowPasteHiddenRange = option.getAllowPasteHiddenRange();
       worksheet.getRange("A1:B3").copy(worksheet.getRange("D10"), option);
       
      Returns:
      true if hidden cells in the copied range are included in the paste operation; otherwise, false.
    • setAllowPasteHiddenRange

      public void setAllowPasteHiddenRange(boolean allowPasteHiddenRange)
      Sets whether hidden cells in the copied range are included in the paste operation.

      Use this property with IRange.copy(IRange,PasteOption) to determine whether content from hidden rows or columns is pasted. A new PasteOption instance allows pasting hidden ranges by default.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"Alice", 100},
           {"Bob", 200}
       });
       worksheet.getRange("2:2").setHidden(true);
      
       PasteOption option = new PasteOption();
       option.setAllowPasteHiddenRange(false);
       worksheet.getRange("A1:B3").copy(worksheet.getRange("D10"), option);
       
      Parameters:
      allowPasteHiddenRange - true if hidden cells in the copied range are included in the paste operation; otherwise, false.
    • getPasteType

      public EnumSet<PasteType> getPasteType()
      Gets the paste types that are applied during a range copy operation.

      Use this method with IRange.copy(IRange,PasteOption) to inspect or reuse the current paste configuration. A new PasteOption instance returns a set containing PasteType.Formulas and PasteType.Formats by default.

      
       worksheet.getRange("A1").setFormula("=1+1");
       worksheet.getRange("A1").getInterior().setColor(Color.GetYellow());
      
       PasteOption option = new PasteOption();
       option.setPasteType(EnumSet.of(PasteType.Values));
       worksheet.getRange("A1").copy(worksheet.getRange("B1"), option);
       EnumSet<PasteType> pasteTypes = option.getPasteType();
       
      Returns:
      The current set of PasteType values that controls which parts of the source range are pasted.
    • setPasteType

      public void setPasteType(EnumSet<PasteType> pasteType)
      Sets the paste types that are applied during a range copy operation.

      Use this method with IRange.copy(IRange,PasteOption) to specify which parts of the source range are pasted. A new PasteOption instance includes PasteType.Formulas and PasteType.Formats by default.

      
       worksheet.getRange("A1").setFormula("=1+1");
       worksheet.getRange("A1").getInterior().setColor(Color.GetYellow());
      
       PasteOption option = new PasteOption();
       option.setPasteType(EnumSet.of(PasteType.Values));
       worksheet.getRange("A1").copy(worksheet.getRange("B1"), option);
       
      Parameters:
      pasteType - The set of PasteType values that controls which parts of the source range are pasted.