Làm cách nào để xuất dữ liệu từ bảng html trong excel bằng jquery?

Trong hướng dẫn này, tôi sẽ chia sẻ một plug-in tuyệt vời để xuất dữ liệu bảng HTML sang trang tính excel chỉ bằng một nút bấm

The plug-in is based on jQuery which is light-weight, only 3Kb of the JS file. You need to include the plug-in JS file in the section, after the reference of jQuery JS file. Simply refer the table ID or class in the jQuery code that you want to export to the excel spreadsheet with a few options and you are done.

Bản demo của bảng HTML jQuery để xuất excel

Đối với bản trình diễn, tôi đang tạo một bảng dựa trên các lớp Bootstrap để đơn giản hóa quy trình. Bạn có thể sử dụng bất kỳ bảng nào, ngay cả khi không có bất kỳ CSS nào mà bạn muốn xuất

The table contains the tags that define the headings for the table of HTML. The same headers act as the headings in the excel sheet after export. A few options may also be set like tab name in the excel sheet, the file name of excel etc in the jQuery code that I will explain after the demo.

Đối với bản demo này, tệp xuất excel sẽ tải xuống khi tải trang demo. Bản minh họa tiếp theo cho thấy việc tải xuống tệp khi nhấp vào nút, hãy xem

Xem bản demo và mã trực tuyến

Đánh dấu của bảng

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

   

Chủ Đề