The invention discloses an in-situ battery accessory for an X-ray diffractometer, which comprises an upper top cover, a lower top cover, a central bolt, a beryllium window, a central cavity insulator, a negative electrode conductive seal, a central electrode, a central insulator, and a center bolt. The upper end is installed in the second threaded hole, the beryllium window is installed on the bottom of the second threaded hole, the beryllium window closes the second through hole, the center cavity insulator is installed in the through hole of the center bolt, and the center cavity insulator The upper end is in contact with the beryllium window, the negative electrode conductive seal is installed in the inner cavity of the central cavity insulator, the central insulator is fixedly installed on the first through hole, the central electrode is fixedly installed in the through hole of the central insulator, the upper end of the central electrode and Negative conductive seal connection. The device has the advantages of simple design, convenient use and good air sealing performance. The invention also discloses a heating device, a cooling device for the in-situ battery accessory of the X-ray diffractometer and a method for measuring lithium battery materials by using the in-situ battery accessory of the X-ray diffractometer.