EXECL est très puissant et de nombreuses fonctions ou formules intégrées peuvent considérablement améliorer la capacité de traitement des données. Y a-t-il donc des contrôles similaires sur le Web? Après quelques recherches, j'ai constaté que HandNontable a des formules de support de fonction Excel de base et peut modifier les données en temps réel. De plus, il prend en charge la copie de glisser, Ctrl + C, Ctrl + V, etc. En termes de prise en charge du navigateur, il prend en charge les navigateurs suivants: IE7 +, FF, Chrome, Safari, Opera.
Tout d'abord, les fichiers de bibliothèque pertinents sont introduits. Le support de formule n'est pas inclus dans le HandNontable.full.js et doit être introduit séparément:
<script src = "http://handsontable.github.io/handsontable-mbulejs/lib/jquery/jquery-1.10.2.js"> </ script> <script src = "http://handsontable.github.io/handSontable-Rulejs/lib/handsontable/handsontable.full. rel = "Stylesheet" media = "screen" href = "http://handsontable.github.io/handsontable-minlejs/lib/handsontable/handsontable.full.css"> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/lodash/lodash.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/underscore.string/underscore.string.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/moment/moment.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/moment/moment.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/numeral/numeral.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/numericjs/numeric.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/js-md5/md5.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/js-md5/md5.js"> </ script> <script src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/lib/jstat/jstat.js"> </ script> <script src = "http://handsontable.github.io/handSontable rulejs/lib/rulejs src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/js/parser.js"> </ script> <script src = "http://handsontable.github.io/handsontable-red-rejs/lib/rulejs/js/parser.js"> </ script> src = "http://handsontable.github.io/handsontable-mbulejs/lib/rulejs/js/rulejs.js"> </ script> <script src = "http://handsontable.github.io/handsontable rulejs/lib/handsontable/handsontable.formula.js"> </ script>
Mettez un conteneur Div en HTML pour stocker le contrôle de mains:
<body> <div id = "HandNontable-Code"> </div> </ body>
Dans le code JavaScript, obtenez d'abord le conteneur div, puis créez le contrôle de la table:
<script type = "text / javascript"> $ (document) .ready (function () {var data1 = [['= $ b $ 2', "Maserati", "Mazda", "return 1 + 2;", 'return dataaccess.getScalar ("Select top 1 nom de cloud_users où cellulephone = 15895211486"); "= a $ 1"], [20095211486 ");" = a $ 1 "], [2009521141,"); "= a $ 1"], [20095, 2941, ");" = a $ 1 "]. 4303, 354, 5814], [2010, 5, 2905, 2867, '= sum (a4, 2, 3)', '= $ b1'], [2011, 4, 2517, 4822, 552, 6127], [2012, '= sum (a2: a5)', '= sum (b5, e3)', '= a2 / b2', 12, 4151); négatifValueRenderer (instance, td, row, col, prop, valeur, celluleproperties) {handNontable.rederers.texTrender.Apply (ceci, arguments); //cellproperties.readonly = true; // Retourne le format de données DataType: "html", // "xml", "html", "script", "json", "jsonp", "text". $ (# msg "). html (decodeuri (données)); // Hideloading ();}, // Appelez la fonction qui exécute l'erreur: fonction () {// demande d'erreur // alerte ('erreur')}}); TD.APPEDCHILD (NEWVALUE);} // Si la ligne contient un nombre négatif if (parseInt (Valeur, 10) négatifValueRender); HandSontable.Helper.Stringefy (this.instance.getData () [Row] [Col]); </cript>La formule de = sum (b5, e3) est fournie par les règles. Return 1 + 2 est un script de code C # implémenté par vous-même. Vous devez cliquer pour analyser:
Classe publique CSEGINE: ihttphandler {private static int count = 0; public void processRequest (httpcontext context) {context.Response.contentType = "text / plain"; essayez {count ++; String ret = ""; String code = context.Request ["code"]. toString (); if (string.isnullorempty (code)) {ret = "Erreur de paramètre"; } else {ScriptOptions Options = ScriptOptions.default .AdDreferences (Assembly.GetAmly (typeof (dbservices.dataaccess))) //.addimports("System.data ") //.addimpports (« dbSmeset »); var state = csharpscript.runasync (code, options) .Result.returnvalue; ret = state.toString (); état = null; options = null; } Console.writeline (count); context.response.write (ret); } catch (exception ex) {// error console.writeLine (count); }} public bool isreusable {get {return false; }}}Exécutez le code comme suit:
Ce qui précède est tout le contenu de cet article. J'espère que cela sera utile à l'apprentissage de tous et j'espère que tout le monde soutiendra davantage Wulin.com.