如何避免我的编码不保存活动表上的数据?

时间:2017-10-21 08:38:38

标签: excel vba excel-vba

我正在使用两张名为“Data”和“Daily”的工作簿。我只是希望我的代码在每日工作表中保存新输入,但不是这样做而是保存在活动工作表中。如果有人能解决这个问题,我将不胜感激。

这是我的代码:

<?php

namespace App\Middleware;

use Fig\Http\Message\StatusCodeInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;


/**
 * Middleware to detect accept is JSON API (application/vnd.api+json) and separate version
 */
class ContentTypeJsonApiVersioning
{

    /**
     * @const string
     */
    const EXPECTED_TYPE_JSON_API = 'application/vnd.api+json';


    /**
     * Execute the middleware.
     *
     * @param ServerRequestInterface $request
     * @param ResponseInterface      $response
     * @param callable               $next
     *
     * @throws \InvalidArgumentException
     *
     * @return ResponseInterface
     */
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
    {
        // error: return response with code: 415
        $return       = $response->withStatus(StatusCodeInterface::STATUS_UNSUPPORTED_MEDIA_TYPE);
        $acceptHeader = $request->getHeader('Accept');

        if (isset($acceptHeader[0])) {

            $data = $this->_processAcceptHeader($acceptHeader[0]);

            if (self::EXPECTED_TYPE_JSON_API === $data['accept']) {

                // continue processing
                $return = $next($request->withAttribute('version', $data['version']), $response);
            }
        }

        return $return;
    }


    /**
     * @param string $acceptHeader
     * @return array
     */
    protected function _processAcceptHeader(string $acceptHeader) : array
    {
        // expected: "application/vnd.api+json; version=2.1"
        $data   = \explode(';', $acceptHeader);
        $return = [
            'accept'  => $data[0],
            'version' => '1'
        ];

        // on 2 items, 2nd is version parameter
        if (2 === \count($data)) {

            // split: "version=2.1" to "2.1"
            list(,$return['version']) = \explode('=', \trim($data[1]));
        }

        return $return;
    }

}

1 个答案:

答案 0 :(得分:1)

尝试以这种方式添加对Daily sheet的引用:

With Sheets("Daily")
   .Cells(sonsat, 1) = TextBox1 'dot at the beginning is very important...
   .Cells(sonsat, 2) = TextBox2
   .Cells(sonsat, 3) = TextBox3
   .Cells(sonsat, 4) = TextBox4
   .Cells(sonsat, 5) = TextBox5
end with