Near-field ptychography provides advantages over far-field ptychography that large field-of-view (FOV) can be imaged with fewer diffraction images, and with weaker requirements on the detector dynamic range and beam coherence, which has drawn attention recently. However, the propagation distance of traditional angular spectrum (AS) method is limited and the reconstruction of the smallest resolvable object detail is restricted by the sensor's pixel size. To this end, we propose an adaptive-window angular spectrum (AWAS) algorithm to solve both problems by adding the window adaptively associated with the propagation distance and avoid the extra computations via extra scaling factors. Meanwhile, it features validity for the independent sample size and the sample number on the observation plane. This algorithm is strictly deduced from the Rayleigh-Sommerfeld formula and based on the linear convolution, which can be evaluated by fast Fourier transform effectively. The burden of calculations is comparable to traditional AS method. The performance has been achieved both in two-dimensional and three-dimensional near-field ptychography with simulations and experiments. This method will make near-field ptychography more practical and can be used in X-ray or electron-microscopy and other computational imaging techniques.