Google-RestApi

 view release on metacpan or  search on metacpan

lib/Google/RestApi/SheetsApi4/Request/Spreadsheet/Worksheet/Range.pm  view on Meta::CPAN

  my $p = $check->(@_);

  # pasteData requires a GridCoordinate (single cell), not a GridRange
  my $range_index = $self->range_to_index();
  my %coordinate = (
    sheetId     => $range_index->{sheetId},
    rowIndex    => $range_index->{startRowIndex},
    columnIndex => $range_index->{startColumnIndex},
  );

  my %request = (
    coordinate => \%coordinate,
    data       => $p->{data},
    type       => $p->{type},
  );
  if ($p->{html}) {
    $request{html} = bool(1);
  } else {
    $request{delimiter} = $p->{delimiter};
  }

  $self->batch_requests(pasteData => \%request);

  return $self;
}

sub text_to_columns {
  my $self = shift;

  state $check = signature(
    bless => !!0,
    named => [
      delimiter      => Optional[Str],
      delimiter_type => Str, { default => 'AUTODETECT' },
    ],
  );
  my $p = $check->(@_);

  my %request = (
    source        => $self->range_to_index(),
    delimiterType => $p->{delimiter_type},
  );
  $request{delimiter} = $p->{delimiter} if defined $p->{delimiter};

  $self->batch_requests(textToColumns => \%request);

  return $self;
}

sub find_replace {
  my $self = shift;

  state $check = signature(
    bless => !!0,
    named => [
      find               => Str,
      replacement        => Str, { default => '' },
      match_case         => Bool, { default => 0 },
      match_entire_cell  => Bool, { default => 0 },
      search_by_regex    => Bool, { default => 0 },
      include_formulas   => Bool, { default => 0 },
    ],
  );
  my $p = $check->(@_);

  $self->batch_requests(
    findReplace => {
      range            => $self->range_to_index(),
      find             => $p->{find},
      replacement      => $p->{replacement},
      matchCase        => bool($p->{match_case}),
      matchEntireCell  => bool($p->{match_entire_cell}),
      searchByRegex    => bool($p->{search_by_regex}),
      includeFormulas  => bool($p->{include_formulas}),
    },
  );

  return $self;
}

sub set_data_validation {
  my $self = shift;

  state $check = signature(
    bless => !!0,
    named => [
      rule => HashRef,
    ],
  );
  my $p = $check->(@_);

  $self->batch_requests(
    setDataValidation => {
      range => $self->range_to_index(),
      rule  => $p->{rule},
    },
  );

  return $self;
}

sub clear_data_validation {
  my $self = shift;

  $self->batch_requests(
    setDataValidation => {
      range => $self->range_to_index(),
    },
  );

  return $self;
}

sub data_validation_list {
  my $self = shift;

  state $check = signature(
    bless => !!0,
    named => [
      values        => ArrayRef,
      strict        => Bool, { default => 1 },
      show_custom   => Bool, { default => 0 },
      input_message => Optional[Str],
    ],
  );
  my $p = $check->(@_);

  my @condition_values = map { { userEnteredValue => $_ } } @{ $p->{values} };
  my %rule = (
    condition => {
      type   => 'ONE_OF_LIST',
      values => \@condition_values,
    },
    strict       => bool($p->{strict}),



( run in 1.498 second using v1.01-cache-2.11-cpan-99c4e6809bf )