我目前使用这样的东西在单元格中插入内联字符串:
new Cell()
{
CellReference = "E2",
StyleIndex = (UInt32Value)4U,
DataType = CellValues.InlineString,
InlineString = new InlineString(new Text( "some text"))
}
Run Code Online (Sandbox Code Playgroud)
但是\n
插入换行符不起作用,我该怎么做呢?
谢谢
响应
new Cell(
new CellValue("string \n string")
)
{
CellReference = "E2",
StyleIndex = (UInt32Value)4U,
DataType = CellValues.String
}
Run Code Online (Sandbox Code Playgroud) 我正在使用一个简单的基于Web的PHP应用程序,它将表格作为电子表格输出
header("Content-Disposition: attachment; filename=" . $filename . ".xls");
header("Content-Type: application/vnd.ms-excel");
//inserts tab delimited text
Run Code Online (Sandbox Code Playgroud)
但我发现下载的电子表格打开为只读文件,必须在本地保存(在Windows上的Excel中),类型更改为XLS(来自HTML).有没有办法正确设置filetype的属性,以便进行简单的保存不需要更正文件类型?
文件是否以安全性方式下载为只读,这是不正常的?
此外,我不喜欢在Excel或OpenOffice(在Linux上)打开电子表格时创建的自动边框.我宁愿没有边框格式.文件中是否有一种方法可以指定没有添加的格式或者是否内置到这些应用程序中?
有了Spreadsheet::WriteExcel
,我可以创建一个新的工作簿,但是如果我想打开现有的书并修改某些列呢?我怎么做到这一点?
我可以解析工作表中的所有数据,Spreadsheet::ParseExcel
然后使用,然后使用某些行/列中的新值将其写回Spreadsheet::WriteExcel
.有没有一个模块已经结合了这两个?
主要是我只想打开一个.xls
,覆盖某些行/列,并保存它.
如果在"表格"("Sheet1","Sheet2"等),"ThisWorkbook"和"Modules"("Module1"等)中运行VBA代码,会有什么不同?
换句话说,在哪些情况下应该使用哪一个?
我正在尝试从电子表格中读取日期列和时间列.我可以从工作表中退出日期列,但不能退出时间列.
例如,我的工作表将包含以下形式的行:
11/2/2012 12:15:01
我有以下代码来获取日期列:
while(cellIterator.hasNext()) {
HSSFCell cell = (HSSFCell)cellIterator.next();
switch(cell.getCellType()){
case HSSFCell.CELL_TYPE_NUMERIC:
HSSFCellStyle style = cell.getCellStyle();
if (HSSFDateUtil.isCellDateFormatted(cell))
{
d = (Date)getDateValue(cell);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
System.out.println(dateFormat.format(d));
}
}
}
protected static Object getDateValue(HSSFCell cellDate)
{
double numericDateValue = cellDate.getNumericCellValue();
Date date = HSSFDateUtil.getJavaDate(numericDateValue);
return date;
}
Run Code Online (Sandbox Code Playgroud)
如你所见,我用
HSSFDateUtil.isCellDateFormatted(细胞)
检查单元格中是否有日期值.我想知道我是否可以使用任何函数检查单元格是否具有时间值.
excel表来自外部来源.所以,我将无法对其格式进行任何修改.
现在,我得到日期列的正确日期值.但是,对于时间列,我得到了
1899年12月31日
作为所有行的结果
是的,所以我检查了Roo.伟大的宝石和所有,并有一个真正的基本应用程序,没有没有模型.基本的控制器,类和视图,我似乎无法上传电子表格,因为我收到OLE2 signature is invalid
错误.我有以下基本设置
调节器
class SpreadsheetServiceController < ApplicationController
def new
end
def create
parser = SpreadsheetTagService.new(params[:spreadsheet][:file])
respond_to do |format|
format.all {render :json => 'Done'}
end
end
end
Run Code Online (Sandbox Code Playgroud)
SpreadsheetTagService
class SpreadsheetTagService
include Roo
def initialize(uploaded_file)
@tmp_destination = "#{Rails.root}/tmp/tag-import.xls"
@file_path = save_file_to_tmp(uploaded_file)
@file = File.new(@file_path)
read_file(@file)
end
private
def save_file_to_tmp(uploaded_file)
FileUtils.mv(uploaded_file.tempfile.path, @tmp_destination )
@tmp_destination
end
def read_file(file)
@spreadsheet = open_spreadsheet(file)
@spreadsheet.each_with_pagename do |name,sheet|
Rails.logger.debug( sheet )
end
end
def open_spreadsheet(file)
case File.extname(file.path)
when ".csv" then Csv.new(file.path, nil, :ignore)
when …
Run Code Online (Sandbox Code Playgroud) 相当于......
<cfspreadsheet action="read" src="#form.uploadedFile#" query="mycontent" >
Run Code Online (Sandbox Code Playgroud)
在cfscript?
cfscript有spreadSheetRead(fileName) - 但结果是一个带有文件元数据的对象,即使我指定了工作表,它也只返回元数据而不是行列数据.
我需要遍历行...我该怎么做?
我试图避免退出我的脚本格式,并插入'cf'标签格式...任何帮助表示赞赏.
我创建了一个包含五列的Google电子表格;
一旦用户填写前三列中的值,它就必须调用第三方API并填充第四和第五列中的值(响应).
是否可以在Google Spreadsheet中为API调用编写代码?是否可以在Google电子表格中调用并获取外部API的响应?
问题:在Google表格中,仅使用内置函数,如何编写过滤器以根据每行中不存在于另一个范围的有效值列表中的列来排除记录.
细节
我正在使用Google表格编写一份财务电子表格,其中我的所有费用和收入都输入到一张名为"交易"的表格中.我有一个名为常数的单独表格,其中列出了收入类别列表和费用类别列表.
以下是一些用于问题的示例数据:
常量
交易
我有一张名为ByMonth的工作表,我想在一个部分显示所有费用交易,并在一个单独的部分显示所有收入交易.目标:
我需要在谷歌工作表功能基本上做这个SQL查询:
select date, category, amount from transactions
where category not in (
select * from expense_categories
)
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何让Google表格让我用他们的功能做一个IN概念.
这是一个单元函数表达式,我用它来根据日期字段过滤行:
=filter(Transactions!A2:C,
DATEVALUE(Transactions!A2:A) >= date(2015,4,1),
DATEVALUE(Transactions!A2:A) <= date(2015,4,30)
)
Run Code Online (Sandbox Code Playgroud)
我将向filter()函数添加第三个条件,并且第三个条件将以某种方式将每行数据的Category列与有效费用或收入类别列表进行比较并返回布尔值.
以下是我尝试过的其他一些事情,但无济于事,包括MATCH,ARRAYFORMULA等的一些变化:
=filter(Transactions!A2:C, row(Transactions!B2:B) = UNIQUE(Constants!A2:A))
=filter(Transactions!A2:C, Transactions!B2:B = UNIQUE(Constants!A2:A))
=filter(Transactions!A2:C, Transactions!B2:B = Constants!A2:A)
Run Code Online (Sandbox Code Playgroud)
有什么建议?
是否可以在签名脚本上传递参数?
我有一个电子表格,并为每个电子表格制作了几个签名功能的按钮。
示例函数:
function foo(){
return "bar";
}
Run Code Online (Sandbox Code Playgroud)
在单元格上调用此函数
=foo()
Run Code Online (Sandbox Code Playgroud)
返回我bar
,将此函数签名到按钮
foo
Run Code Online (Sandbox Code Playgroud)
什么也没返回给我,但它当然有效。我的意思是脚本无法将字符串返回到图像(实际上是我的按钮)。无论如何...
带参数的示例函数:
=foo()
Run Code Online (Sandbox Code Playgroud)
在单元格中调用脚本
foo
Run Code Online (Sandbox Code Playgroud)
hello world
按预期返回我
将此签名到我的按钮
function foo(bar){
return bar;
}
Run Code Online (Sandbox Code Playgroud)
导致错误,因为按钮找不到脚本。他正在搜索一个函数名称foo('hello world')
,但(...)
与该函数无关。
那么签名脚本时如何传递参数呢?
目前我有 26 个函数(全部相同,只有 1 个参数变化)来解决这个问题。但是通过传递参数,我可以使用 2 个函数而不是 26 个函数来完成所有这些操作。
spreadsheet ×10
excel ×3
apache-poi ×1
c# ×1
cell ×1
coldfusion ×1
datetime ×1
excel-vba ×1
file-type ×1
formatting ×1
java ×1
line-breaks ×1
openxml ×1
perl ×1
php ×1
readonly ×1
vba ×1
xls ×1