@param \Google_Service_Sheets $googleServiceSheets
@param string                 $file
@param string                 $sheet

@param string                 $range

@return \MercesLab\Component\SpreadsheetClient\TableInterface
340524
public static function createTable(
        \Google_Service_Sheets $googleServiceSheets,
        string $file,
        string $sheet = ClientInterface::DEFAULT_SHEET,
        string $range = ClientInterface::DEFAULT_RANGE
    ): TableInterface {
        return new GoogleTable($googleServiceSheets, $file, $sheet, $range);
    }
1254663
protected function getWorksheetFromExternalSheet($sheet)
    {
        $worksheetFound = null;

        foreach ($this->worksheets as $worksheet) {
            if ($worksheet->getExternalSheet() === $sheet) {
                $worksheetFound = $worksheet;
                break;
            }
        }

        return $worksheetFound;
    }
397494
public function createSpreadsheet($filename = null)
    {
        return (null === $filename) ? new Spreadsheet() : call_user_func(array($this->phpSpreadsheetIO, 'load'), $filename);
    }
70041
public XceliteSheet getSheet(String sheetName) {
    Sheet sheet = workbook.getSheet(sheetName);
    if (sheet == null) {
      throw new XceliteException(String.format("Could not find sheet named \"%s\"", sheetName));
    }
    return new XceliteSheetImpl(sheet, file);
  }
951510
public function load($file, $range = '') {
        //$range = $range ?: $this->range;
        //if (!isset($this->lang[$range])) {
        //    $this->lang[$range] = [];
        //}

        // 批量定义
        if (is_string($file)) {
            $file = [$file];
        }

        $lang = [];

        foreach ($file as $_file) {
            if (is_file($_file)) {
                // 记录加载信息
                $_lang = include $_file;
                if (is_array($_lang)) {
                    $lang = $_lang+ $lang;
                }
            }
        }

        if(!$lang) {
            return false;
        }

        if($range) {
            if (!isset($this->range[$range])) {
                $this->range[$range] = [];
            }
            $this->range[$range] = $lang + $this->range[$range];
        }
        else {
            $this->lang = $lang + $this->lang;
        }
    }
69746
public function append(array $value, string $valueInputOption = 'RAW', string $insertDataOption = 'OVERWRITE')
    {
        $range = $this->ranges();

        $valueRange = new \Google_Service_Sheets_ValueRange();
        $valueRange->setValues($value);
        $valueRange->setRange($range);

        $optParams = [
            'valueInputOption' => $valueInputOption,
            'insertDataOption' => $insertDataOption,
        ];

        $response = $this->getService()->spreadsheets_values
            ->append($this->spreadsheetId, $range, $valueRange, $optParams);

        return $response;
    }
1334000
public function delete($table, $hash, $range = null, Context\Delete $context = null)
    {
        if (null !== $this->logger) {
            $this->log('Delete on table '.$table);
        }

        // Primary key
        $hash = new Attribute($hash);
        $key = array(
            'HashKeyElement' => $hash->getForDynamoDB()
        );

        // Range key
        if (null !== $range) {
            $range = new Attribute($range);
            $key['RangeKeyElement'] = $range->getForDynamoDB();
        }

        $parameters = array(
            'TableName' => $table,
            'Key'       => $key
        );

        if (null !== $context) {
            $parameters += $context->getForDynamoDB();
        }

        if (null !== $this->logger) {
            $this->log('Delete request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->deleteItem($parameters);

        if (null !== $this->logger) {
            $this->log('Delete request response : '.print_r($response, true), Logger::DEBUG);
        }

        // Update write counter
        $this->addConsumedWriteUnits($table, floatval($response['ConsumedCapacityUnits']));

        return $this->populateAttributes($response);
    }
1331858
@SuppressWarnings("unchecked")
	public T setSheet(String sheetName) {
		this.sheet = this.workbook.getSheet(sheetName);
		if (null == this.sheet) {
			this.sheet = this.workbook.createSheet(sheetName);
		}
		return (T) this;
	}
152297
private function exportQuery(
        FromQuery $export,
        TemporaryFile $temporaryFile,
        string $writerType,
        int $sheetIndex
    ): Collection {
        $query = $export->query();

        $count = $export instanceof WithCustomQuerySize ? $export->querySize() : $query->count();
        $spins = ceil($count / $this->getChunkSize($export));

        $jobs = new Collection();

        for ($page = 1; $page <= $spins; $page++) {
            $serializedQuery = new SerializedQuery(
                $query->forPage($page, $this->getChunkSize($export))
            );

            $jobs->push(new AppendQueryToSheet(
                $export,
                $temporaryFile,
                $writerType,
                $sheetIndex,
                $serializedQuery
            ));
        }

        return $jobs;
    }
981496
protected function createSheet($name) {
    $name = \Psc\PHPExcel\Helper::sanitizeSheetTitle($name);
    $this->excel->addSheet(new PHPExcel_Worksheet($this->excel, $name));
    $this->excel->setActiveSheetIndexByName($name);
    $this->sheet = $this->excel->getActiveSheet();
    
    $this->setRow(1);
  }
935082
public static function setSheet($sheet=0, $title=NULL, $normalizeTitle=false)
    {
        self::resetSheet();

        if (is_object($sheet)) {
            
            self::$_objSheet = &$sheet;
        } 
        elseif (is_numeric($sheet) && $sheet>=0 && self::$_objSpreadsheet) {

            /* Sheets Check */
            $sheetCount = self::$_objSpreadsheet->getSheetCount();
            if ($sheet >= $sheetCount) {
                for ($i=$sheetCount; $i <= $sheet; $i++) { 
                    self::$_objSpreadsheet->createSheet($i);
                }
            }
            // Select sheet
            self::$_objSheet = self::$_objSpreadsheet->setActiveSheetIndex($sheet);
        }
        elseif (is_null($sheet) && self::$_objSpreadsheet) {
            // Auto create a sheet without index
            self::setSheet(self::getSheetCount());
        }
        else {
            throw new Exception("Invalid or empty PhpSpreadsheet Object for setting sheet", 400);
        }

        // Sheet Title
        if ($title) {
            // Auto-normalize title rule 
            if ($normalizeTitle) {
                /**
                 * @see PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
                 */
                // Some of the printable ASCII characters are invalid:  * : / \ ? [ ]
                $title = str_replace(self::$_invalidCharacters, '', $title);
                // Maximum 31 characters allowed for sheet title
                $title = mb_substr($title, 0, 31);
            }

            self::$_objSheet->setTitle($title);
        }

        return new static();
    }
1056476
public function read(
        string $sheet = ClientInterface::DEFAULT_SHEET,
        string $range = ClientInterface::DEFAULT_RANGE,
        int $offset = ClientInterface::DEFAULT_OFFSET,
        int $limit = ClientInterface::DEFAULT_LIMIT
    ): array {
        return $this->doRead($this->file, $sheet, $range, $offset, $limit);
    }
856202
private function writeSheets($sheets) {
        foreach ($sheets as $sheet) {
            fseek($sheet->getStream(), 0);
            stream_copy_to_stream($sheet->getStream(), $this->stream);
            fclose($sheet->getStream());
        }
    }
713240
def download_sheet(self, file_path, sheet_id, cell_range):
        

        result = self.service.spreadsheets().values().get(
            spreadsheetId=sheet_id,
            range=cell_range,
        ).execute()

        values = result.get('values', [])

        with open(file_path, newline='', encoding='utf-8', mode='w') as f:
            writer = csv.writer(f, lineterminator='\n')

            for row in values:
                writer.writerow(row)
774410
public function convert(\stdClass $table, $excelFile = NULL, $removeEmpty = TRUE) {
    $excelFile = $excelFile ?: $this->v->validateUploadedFile('excelFile');
    
    $reader = PHPExcel_IOFactory::createReaderForFile((string) $excelFile);
    $excel = $reader->load((string) $excelFile);
    $sheet = $excel->getSheet(0);
    
    $columns = isset($table->columns) ? (array) $table->columns : array();
    
    $nullValue = ''; // sadly json macht aus NULL den string "null" in js
    $data = array();
    $mCell = 0;
    foreach ($sheet->getRowIterator() as $wsRow) {
      $row = array();
      $empty = TRUE;
      foreach ($wsRow->getCellIterator() as $cell) {
        // $cell->getDataType() gibts sogar auch

        $cellIndex = h::getColumnIndex($cell->getColumn());
        $mCell = max($mCell, $cellIndex+1);
      
        $row[$cellIndex] = $value = $this->convertValue(
                            $cell->getValue(),
                            isset($columns[$cellIndex]) && isset($columns[$cellIndex]->type) ? $columns[$cellIndex]->type : NULL
                           );
        if ($value != '') {
          $empty = FALSE;
        }
      }
      
      if (!$removeEmpty || !$empty) {
        ksort($row);
        $data[] = array_replace(array_fill(0, $mCell, $nullValue), $row);
      }
    }

    return new ServiceResponse(Service::OK, $data, ServiceResponse::JSON_UPLOAD_RESPONSE);
  }
545525
function Spreadsheet_Excel_Writer_Workbook($filename)
    {
        // It needs to call its parent's constructor explicitly
        $this->Spreadsheet_Excel_Writer_BIFFwriter();

        $this->_filename         = $filename;
        $this->_parser           =  new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version);
        $this->_1904             = 0;
        $this->_activesheet      = 0;
        $this->_firstsheet       = 0;
        $this->_selected         = 0;
        $this->_xf_index         = 16; // 15 style XF's and 1 cell XF.
        $this->_fileclosed       = 0;
        $this->_biffsize         = 0;
        $this->_sheetname        = 'Sheet';
        $this->_tmp_format       =  new Spreadsheet_Excel_Writer_Format($this->_BIFF_version);
        $this->_worksheets       = array();
        $this->_sheetnames       = array();
        $this->_formats          = array();
        $this->_palette          = array();
        $this->_codepage         = 0x04E4; // FIXME: should change for BIFF8
        $this->_country_code     = -1;
        $this->_string_sizeinfo  = 3;

        // Add the default format for hyperlinks
        $this->_url_format =  $this->addFormat(array('color' => 'blue', 'underline' => 1));
        $this->_str_total       = 0;
        $this->_str_unique      = 0;
        $this->_str_table       = array();
        $this->_setPaletteXl97();
    }
1200710
File appendSheet(final List<WorksheetContent> worksheetContents) throws IOException {
        final ImmutableSet<String> worksheetNames = FluentIterable.from(worksheetContents)
                .transform(new Function<WorksheetContent, String>() {
                    @Nullable @Override public String apply(@Nullable final WorksheetContent worksheetContent) {
                        return worksheetContent.getSpec().getSheetName();
                    }
                }).toSet();
        if(worksheetNames.size() < worksheetContents.size()) {
            throw new IllegalArgumentException("Sheet names must have distinct names");
        }
        for (final String worksheetName : worksheetNames) {
            if(worksheetName.length() > 30) {
                throw new IllegalArgumentException(
                        String.format("Sheet name cannot exceed 30 characters (invalid name: '%s')",
                                worksheetName));
            }
        }

        final XSSFWorkbook workbook = new XSSFWorkbook();
        final File tempFile =
                File.createTempFile(ExcelConverter.class.getName(), UUID.randomUUID().toString() + XLSX_SUFFIX);
        final FileOutputStream fos = new FileOutputStream(tempFile);

        for (WorksheetContent worksheetContent : worksheetContents) {
            final WorksheetSpec spec = worksheetContent.getSpec();
            appendSheet(workbook, worksheetContent.getDomainObjects(), spec.getFactory(), spec.getSheetName());
        }
        workbook.write(fos);
        fos.close();
        return tempFile;
    }