content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />

TMS博文

body {

margin: 0;

}

.blocker {

z-index: 99;

}

div#editor {

width: 100%;

position: relative;

height: 100vh;

}

.excel-container {

height: calc(100% - 70px);

overflow: auto;

}

.readonly .excel-container {

height: 100%;

}

#excel {

height: 100%;

position: relative;

}

#excel>.x-spreadsheet {

height: 100% !important;

}

#toast-container {

z-index: 9999999999 !important;

}

.topbar {

padding: 16px;

height: 38px;

}

.readonly .topbar {

display: none;

}

.topbar>input {

width: 400px;

font-size: 26px;

box-sizing: border-box;

outline: 0;

border: 0;

box-shadow: 0px 1px 0px 0px #dddddd;

padding-right: 80px;

}

.topbar>button {

font-size: 12px;

}

button.btn {

color: #fff;

background: #2185d0;

padding: .5rem 1rem;

display: inline-block;

border-radius: 4px;

transition-duration: .25s;

border: none;

font-size: 14px;

}

#import {

color: #fff;

background: #00aaff;

padding: .25rem .5rem;

display: inline-block;

border-radius: 4px;

transition-duration: .25s;

border: none;

font-size: 14px;

}

@media only screen and (max-width: 767px) {

.topbar>input {

width: 250px;

}

#import {

display: none;

}

}

button.btn:hover {

background: #1678c2;

}

#saveFrm .row {

padding-bottom: 8px;

}

#saveFrm label {

-webkit-user-select: none;

-moz-user-select: none;

-ms-user-select: none;

user-select: none;

}

#saveFrm select {

background: #fafdfe;

height: 28px;

width: 440px;

margin-top: 3px;

line-height: 28px;

border: 1px solid #9bc0dd;

-moz-border-radius: 2px;

-webkit-border-radius: 2px;

}

保存

选择空间

选择分类

私有博文(不公开)

确定

x_spreadsheet.locale('zh-cn');

function initExcel(data) {

var readonly = typeof url('?readonly') !== 'undefined';

if ($('#excel').length == 0) return;

try {

window.excel = x_spreadsheet("#excel", {

mode: readonly ? 'read' : 'edit', // edit | read

showToolbar: readonly ? false : true,

showGrid: true,

showContextmenu: readonly ? false : true,

view: {

// height: () => document.documentElement.clientHeight - 70,

height: () => $('.excel-container').height(),

width: () => document.documentElement.clientWidth,

},

row: {

len: 100,

height: 25,

},

col: {

len: 26,

width: 100,

indexWidth: 60,

minWidth: 60,

},

style: {

bgcolor: '#ffffff',

align: 'left',

valign: 'middle',

textwrap: false,

strike: false,

underline: false,

color: '#0a0a0a',

font: {

name: 'Helvetica',

size: 10,

bold: false,

italic: false,

},

},

})

.loadData(data ? data : {}) // load data

.change(data => {

// save data to db

// console.log(JSON.stringify(data));

});

// data validation

excel.validate()

} catch (err) {

console.warn(err);

}

}

$("#import").click(function () { //点击导入按钮,使files触发点击事件,然后完成读取文件的操作。

$("#files").click();

});

function importHandler() {

var selectedFile = document.getElementById("files").files[0]; //获取读取的File对象

var name = selectedFile.name; //读取选中文件的文件名

// var size = selectedFile.size; //读取选中文件的大小

// console.log("文件名:" + name + "大小:" + size);

var reader = new FileReader(); //这里是核心!!!读取操作就是由它完成的。

reader.readAsText(selectedFile); //读取文件的内容

reader.onload = function () {

try {

$('#title').val(name.replace('.table', ''));

excel.loadData(JSON.parse(this.result));

// initExcel(JSON.parse(this.result));

} catch (err) {

alert(err);

}

};

}

$(function () {

var isComment = typeof url('?comment') !== 'undefined';

var id = url('?id');

var cid = url('?cid');

var spaceId = url('?spaceId');

var dirId = url('?dirId');

var pid = url('?pid');

var readonly = typeof url('?readonly') !== 'undefined';

!readonly && $('#editor').removeClass('readonly');

var blog = null;

var comment = null;

// toastr弹出消息提示插件全局配置设置

toastr.options.positionClass = 'toast-bottom-center';

toastr.options.preventDuplicates = true;

if (isComment) { // comment

$('#title').hide();

if (cid) {

var isFree = typeof url('?free') !== 'undefined';

if (isFree) {

$.get('/free/blog/comment/' + cid, {}, function (data) {

if (data.success) {

comment = data.data;

initExcel(JSON.parse(data.data.content));

} else {

toastr.error(data.data);

}

});

} else {

$.get('/admin/blog/comment/get', {

cid: cid

}, function (data) {

if (data.success) {

comment = data.data;

initExcel(JSON.parse(data.data.content))

} else {

toastr.error(data.data);

}

});

}

} else {

initExcel();

}

$('#save').click(function (event) {

var content = JSON.stringify(excel.getData());

if (!content || !$.trim(content)) {

toastr && toastr.error('博文评论内容不能为空!');

return;

}

if (comment == null) {

$.post('/admin/blog/comment/create', {

basePath: window.location.protocol + '//' + window.location.host +

'/page/index.html',

id: id,

editor: 'Excel',

content: content

}, function (data, textStatus, xhr) {

if (data.success) {

comment = data.data;

toastr && toastr.success('博文评论保存成功!');

(window.parent && window.parent.postMessage) && (window.parent

.postMessage({

action: 'created',

source: 'comment',

comment: data.data,

editor: 'excel'

}, window.location.origin));

} else {

toastr && toastr.error(data.data);

}

}).fail(function () {

toastr && toastr.error('网络传输错误!');

});

} else {

$.post('/admin/blog/comment/update', {

basePath: window.location.protocol + '//' + window.location.host +

'/page/index.html',

id: id,

cid: cid,

version: comment.version,

content: content

}, function (data, textStatus, xhr) {

if (data.success) {

comment = data.data;

toastr && toastr.success('博文评论保存成功!');

(window.parent && window.parent.postMessage) && (window.parent

.postMessage({

action: 'updated',

source: 'comment',

comment: data.data,

editor: 'excel'

}, window.location.origin));

} else {

toastr && toastr.error(data.data);

}

}).fail(function () {

toastr && toastr.error('网络传输错误!');

});

}

});

window.addEventListener && window.addEventListener('message', (evt) => {

if (evt.origin != window.location.origin) return;

if (evt.data.source != 'blogClose') return;

if (evt.data.action == 'isUpdated') {

var updated = false;

var title = $('#title').val();

var content = JSON.stringify(excel.getData());

if (comment) {

updated = (comment.content != content);

} else {

updated = (!!$.trim(content) && content !=

`[{"name":"sheet2","freeze":"A1","styles":[],"merges":[],"rows":{"len":100},"cols":{"len":26},"validations":[],"autofilter":{}}]`

);

}

(window.parent && window.parent.postMessage) && (window.parent

.postMessage({

action: 'isUpdated',

source: 'blogCloseAck',

item: evt.data.item,

updated: updated

}, window.location.origin));

}

}, false);

} else { // blog

if (id) {

if (typeof url('?free') === 'undefined') {

$.get('/admin/blog/get', {

id: id,

inc: false

}, function (data) {

if (data.success) {

if (typeof url('?copy') === 'undefined') { // edit

blog = data.data;

$('#title').val(data.data.title);

if (!readonly) {

window.stompClient = Stomp.over(new SockJS('/ws-lock?blogId=' +

blog

.id));

window.stompClient.debug = function () {};

// this.stompClient.debug = function (msg) { console.log(msg) };

window.stompClient.connect({}, function (frame) {}, function (

err) {

console.error(err);

});

}

} else {

$('#title').val(data.data.title + ' (副本)');

}

initExcel(JSON.parse(data.data.content))

} else {

toastr.error(data.data);

}

});

} else {

var shareId = url('?shareId');

// console.log('shareId: ' + shareId);

if (shareId && shareId != '') {

$.get('/free/blog/share/' + shareId, {

_: new Date().getTime(),

inc: false

}, function (data) {

if (data.success) {

if (typeof url('?copy') === 'undefined') { // edit

blog = data.data;

$('#title').val(data.data.title);

} else {

$('#title').val(data.data.title + ' (副本)');

}

initExcel(JSON.parse(data.data.content))

} else {

toastr.error(data.data);

}

});

} else {

$.get('/free/home/blog/' + id, {

_: new Date().getTime(),

inc: false

}, function (data) {

if (data.success) {

if (typeof url('?copy') === 'undefined') { // edit

blog = data.data.blog;

$('#title').val(data.data.blog.title);

} else {

$('#title').val(data.data.blog.title + ' (副本)');

}

initExcel(JSON.parse(data.data.blog.content))

} else {

toastr.error(data.data);

}

});

}

}

} else {

initExcel();

}

// 博文保存选择,空间 + 分类

var spaces = [];

$('#saveFrm select[name="space"]').change(function (event) {

var sid = $(this).val();

$('#saveFrm select[name="dir"]').empty().append($('').text('(不指定分类)').attr(

'value', ''));

if (sid !== '') {

$.each(spaces, function (index, space) {

if (space.id == sid) {

window._ && (space.dirs = _.sortBy(space.dirs, 'name'));

$.each(space.dirs, function (index, dir) {

if (dir.status != 'Deleted') {

$('#saveFrm select[name="dir"]').append($(

'').text(dir.name).attr(

'value', dir.id));

}

});

var did = localStorage && localStorage.getItem(

'tms-blog-html-dir');

if (_.some(space.dirs, {

id: +did

})) {

$('#saveFrm select[name="dir"]').val(did);

}

return false;

}

});

}

});

window.addEventListener && window.addEventListener('message', (evt) => {

if (evt.origin != window.location.origin) return;

if (evt.data.source != 'blogClose') return;

if (evt.data.action == 'isUpdated') {

var updated = false;

var title = $('#title').val();

var content = JSON.stringify(excel.getData());

if (blog) {

updated = (blog.title != title) || (blog.content != content);

} else {

updated = !!$.trim(title) || (!!$.trim(content) && content !=

`[{"name":"sheet2","freeze":"A1","styles":[],"merges":[],"rows":{"len":100},"cols":{"len":26},"validations":[],"autofilter":{}}]`

);

}

(window.parent && window.parent.postMessage) && (window.parent

.postMessage({

action: 'isUpdated',

source: 'blogCloseAck',

item: evt.data.item,

updated: updated

}, window.location.origin));

}

}, false);

$('#save').click(function (event) {

var title = $('#title').val();

var content = JSON.stringify(excel.getData());

if (!title || !$.trim(title)) {

toastr && toastr.error('博文标题不能为空!');

return;

}

if (!content || !$.trim(content)) {

toastr && toastr.error('博文内容不能为空!');

return;

}

if (blog == null) {

if (spaceId || pid) {

createBlog(spaceId, dirId, pid);

} else {

$.get('/admin/space/listMy', function (data) {

if (data.success) {

spaces = data.data;

$('#saveFrm select[name="space"]').empty().append($(

'')

.text('(不指定空间)').attr('value', ''));

$('#saveFrm select[name="dir"]').empty().append($(

'')

.text(

'(不指定分类)').attr('value', ''));

window._ && (spaces = _.sortBy(spaces, 'name'));

$.each(spaces, function (index, space) {

$('#saveFrm select[name="space"]').append($(

'')

.text(space.name).attr('value', space

.id));

});

var sid = localStorage && localStorage.getItem(

'tms-blog-html-space');

if (_.some(spaces, {

id: +sid

})) {

$('#saveFrm select[name="space"]').val(sid);

$('#saveFrm select[name="space"]').change();

}

var privated = localStorage && localStorage.getItem(

'tms-blog-html-privated');

$('#privated').prop("checked", privated == 'true');

$('#saveModal').modal({

fadeDuration: 200,

clickClose: false

});

}

});

}

} else {

$.post('/admin/blog/update', {

url: window.location.protocol + '//' + window.location.host +

'/page/index.html',

id: blog.id,

version: blog.version,

title: title,

content: content

}, function (data, textStatus, xhr) {

if (data.success) {

blog = data.data;

toastr && toastr.success('博文更新成功!');

(window.parent && window.parent.postMessage) && (window.parent

.postMessage({

action: 'updated',

autoFollow: true,

source: 'blog',

blog: data.data

}, window.location.origin));

} else {

toastr && toastr.error(data.data);

}

}).fail(function () {

toastr && toastr.error('网络传输错误!');

});

}

});

$('#saveFrm .btnOk').click(function (event) {

createBlog();

});

}

function createBlog(spaceId, dirId, pid) {

var title = $('#title').val();

var content = JSON.stringify(excel.getData());

if (!title || !$.trim(title)) {

toastr && toastr.error('博文标题不能为空!');

return;

}

if (!content || !$.trim(content)) {

toastr && toastr.error('博文内容不能为空!');

return;

}

if (blog == null) {

if (!spaceId && !pid) {

$.modal.close();

localStorage && localStorage.setItem('tms-blog-html-space', $(

'#saveFrm select[name="space"]').val());

localStorage && localStorage.setItem('tms-blog-html-dir', $(

'#saveFrm select[name="dir"]').val());

localStorage && localStorage.setItem('tms-blog-html-privated', $('#privated')

.prop(

"checked"));

}

$.post('/admin/blog/create', {

url: window.location.protocol + '//' + window.location.host +

'/page/index.html',

spaceId: spaceId ? spaceId : $('#saveFrm select[name="space"]').val(),

dirId: dirId ? dirId : (spaceId ? '' : $('#saveFrm select[name="dir"]').val()),

pid: pid ? pid : '',

title: title,

content: content,

editor: 'Excel',

privated: spaceId ? false : $('#privated').prop("checked"),

contentHtml: content

}, function (data, textStatus, xhr) {

if (data.success) {

blog = data.data;

toastr && toastr.success('博文保存成功!');

$('#preview').show();

(window.parent && window.parent.postMessage) && (window.parent

.postMessage({

action: 'created',

source: 'blog',

blog: data.data,

editor: 'excel'

}, window.location.origin));

} else {

toastr && toastr.error(data.data);

}

}).fail(function () {

toastr && toastr.error('网络传输错误!');

});

}

}

});

一键复制

编辑

Web IDE

原始数据

按行查看

历史

excel html id,excel.html相关推荐

  1. VB 6.0中如何访问EXCEL 2007及EXCEL 2010

    问题及分析过程 最近一段时间在使用VB 6.0开发一个OFFICE考试系统,理想的情况是支持WINDOWS XP,WINDOWS 7,WINDOWS 8,Office 2003和Office 2010 ...

  2. .Net NPOI 根据excel模板导出excel、直接生成excel

    一.根据Excel模板导出excel 1.导入NPOI.dll  2.DAL中添加类ExportExcel.cs using NPOI.SS.UserModel; using System; usin ...

  3. python如何修改excel数据库_python学习笔记-day7-2-【python从mysql数据库导数据到excel,读excel,修改excel】...

    这节说下如何用python把数据库里的数据导出到excel里,并如何读取excel, 修必excel等操作. 一.用python把数据库里的数据导出到excel里 1.导入如下的模块,没有的话需要安装 ...

  4. thinkphp用phpexcel读取excel,并修改列中的值,再导出excel,带往excel里写入图片

    <?phpclass GetpriceAction extends AdministratorAction {// 文件保存路径protected $savepath; // 允许上传的文件类型 ...

  5. PHP导入Excel和导出Excel

    导入Excel基本思路: 接收前端传过来的Excel文件 将Excel文件转化为一个数组 将数组导入到数据库 从百度下载一个PHPExcel类:https://github.com/PHPOffice ...

  6. Flex通过Java读取Excel(详细流程)----Excel在客户端(DataGrid动态根据Excel生成)

    2011-03-06 23:57:00|  分类: flex/flash |  标签:excel  flex  java  客户端  as3xls   |字号大中小  订阅 在网上查了很久的资料,就是 ...

  7. excel网页服务器端,Excel服务VI――用Excel Web Services创建应用程

    译者:fanjy  来源:http://blogs.msdn.com/excel 发表于:2006年7月7日 Excel Services part 6: Building applications ...

  8. excel冻结窗口_你会Excel吗?14个Excel神奇功能+8个Excel小技巧+Excel常见快捷键,提升办公效率...

    14个Excel神奇功能+8个Excel小技巧+Excel常见的一些快捷键,让你的Excel技能6得飞起,每天都能提前2小时下班. 14个Excel神奇功能 一.<Excel如何快速还原隐藏行& ...

  9. js导出EXCEL js导出EXCEL

    参考一:http://wenku.baidu.com/view/7b81f3eb6294dd88d0d26b57.html 参考二: js导出EXCEL js导出EXCEL <html> ...

最新文章

  1. php多关键词精确查找,搜索引擎,全文搜索_请问有没有搜索引擎能做到Like级别的任意关键词精确查询?,搜索引擎,全文搜索,lucene,elasticsearch,百度 - phpStudy...
  2. itoa函数的实现(不同进制)
  3. 【转】从源码分析Handler的postDelayed为什么可以延时?
  4. VC++ 打开文件夹,保存文件等对话框的调用
  5. 日期DatePicker与时间TimePicker控件
  6. js删除两个集合中共同元素_多个集合中的共同和独特元素
  7. PRD之道:4个撰写PRD的关键思路
  8. 尽善尽美之作《Python Qt GUI与数据可视化编程》
  9. java dem数据格式解析_ArcGIS读取dem格式数据
  10. 算法竞赛入门-刽子手游戏(Hangman Judge )
  11. 中间状态+三方预约下单接口测试项目
  12. 如把联想电脑计算机图标放在桌面上,桌面无“我的电脑”图标
  13. Autofill Framework(自动填写)用法详解
  14. 用Python数据处理分析入门必备系列文章:环境安装
  15. mysql中on用法_详解mysql中的Using与On的用法
  16. 北京地铁线路图(最新-非常实用)
  17. 面试经历---广东耶萨智能科技股份有限公司(2016年01月11日上午面试)
  18. DedeCMS-Dede伪原创自动采集发布
  19. c++数据结构与算法(6)——数组(螺旋矩阵)
  20. Atlassian JIRA服务器模板注入漏洞复现(CVE-2019-11581)

热门文章

  1. LInux系统木马植入排查分析 及 应用漏洞修复配置(隐藏bannner版本等)
  2. 7-14 与数据库相连
  3. 103.二叉树的锯齿形层次遍历:DFS解法
  4. ubuntu 中 notepad 安装
  5. 设计测试用例的7点原则
  6. Django之Model组件
  7. 1026 逃跑的拉尔夫
  8. 实验三:跟踪分析Linux内核的启动过程
  9. 2014ACM/ICPC亚洲区西安站 F题 color (组合数学,容斥原理)
  10. Vijos P1740聪明的质检员