Innov-AI
    Documentation | MentDB Weak Server
Excel(X) to SQL Database

  • Excel:
  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	excel load "excelId" "/Users/jimmitry/Desktop/file.xls";
    	-> "[nb_row]" (excel sheet max_row "excelId" "sheet1");
    
    	for (-> "[i_row]" 0) (< [i_row] [nb_row]) (++ "[i_row]") {
    	
    		-> "[A]" (excel cell get "excelId" "sheet1" [i_row] 0);
    		-> "[B]" (excel cell get "excelId" "sheet1" [i_row] 1);
    		-> "[C]" (excel cell get "excelId" "sheet1" [i_row] 2);
    		sql dml "session1" (concat "insert into products (id, name, quantity) values (" (sql encode [A]) ", " (sql encode [B]) ", " (sql encode [C]) ");");
    	
    	};
    
    	excel close "excelId";
    	sql disconnect "session1";
    
    } {
    
    	try {excel close "excelId";} {} "[err]";
    	try {sql disconnect "session1";} {} "[err]";
    
    } "[err]";
  • ExcelX:
  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	excelx load "excelId" "/Users/jimmitry/Desktop/file.xls";
    	-> "[nb_row]" (excelx sheet max_row "excelId" "sheet1");
    
    	for (-> "[i_row]" 0) (< [i_row] [nb_row]) (++ "[i_row]") {
    	
    		-> "[A]" (excelx cell get "excelId" "sheet1" [i_row] 0);
    		-> "[B]" (excelx cell get "excelId" "sheet1" [i_row] 1);
    		-> "[C]" (excelx cell get "excelId" "sheet1" [i_row] 2);
    		sql dml "session1" (concat "insert into products (id, name, quantity) values (" (sql encode [A]) ", " (sql encode [B]) ", " (sql encode [C]) ");");
    	
    	};
    
    	excelx close "excelId";
    	sql disconnect "session1";
    
    } {
    
    	try {excelx close "excelId";} {} "[err]";
    	try {sql disconnect "session1";} {} "[err]";
    
    } "[err]";
Services     Supporters     Contact     About     Legal notice © 2024