Flow cytometer is a powerful tool for the quantitative analysis of a large population of cells. A key factor determining the measurement accuracy and system stability is the illumination beam. The conventional beam shaper is composed of multiple geometrical optical elements, which should be precisely calibrated to produce elliptical Gaussian beams. It is difficult to control the sizes and positions of the focal spots formed by different wavelengths. A new beam shaping method based on diffractive optical element (DOE) is developed for rectangular flattop spots with multi-wavelength illumination. Its benefits include high simplicity, design flexibility, uniform illumination, and multifunctionality.