Ruport目前自带支持PDF,HTML,CSV,TXT格式输出,如果想打印.xml,.bat报表怎么办?
本例将以XML格式为例,实现Ruport::Formatter的另一种自定义应用。
Ruport的应用参考: Ruby Ruport实践—简单报表系统
注:其他格式的报表只需要修改renders对应的内容(如希望保存为.bat格式,将renders :xml改为renders :bat),模板输出内容均用
"output<<"方法进行输出即可
一、在ReportOutputController中添加xml格式
class ReportXml < Ruport::Formatter
renders :xml, :for => ReportOutputController
build :data_sheet do
eval(options[:outputContent])
end
end
二、report_templates中定义为如下内容的模板
output<<"<products>"
data.each do |d|
output<<"<product>"
output<<"<title>#{d.title}</title><type>#{d.description}</type><price>#{d.price}</price>"
output<<"</product>"
end
output<<"</products>"
注:为了测试方便,可将 "eval(options[:outputContent])"直接替换成模板内容
......
转帖:http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/
This snippet shows how root access can be requested inside an application in order to write a file into a place we do not have permission to access usually. Requesting root access will only work if your phone allows it, or it has been ‘rooted’ (hacked to allow superuser permissions).
view plaincopy to clipboardprint?
Process p;
try {
// Preform su to get root privledges
p = Runtime.getRuntime().exec("su");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("echo \"Do I have root?\" >/s ......
1.连接Access的连接字符串
string strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @FileName;
2.连接Excel
string strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + @FileName + ";Extended Properties=Excel 8.0;"; ......
public List<string> GetTables()
{
List<string> Tables = new List<string>();
using (OleDbConnection Con = new OleDbConnection(StrCon))
{
if (Con.State == ConnectionState.Closed)
{
Con.Open();
}
DataTable schemaTable = Con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[] { nu ......
sqlite时间函数(转)
2007年12月10日 星期一 13:33
转贴原因:最近设计了一个跨数据库的函数,来测试测试sqlite。
SQLite分页显示:Select * from news order by id
desc Limit 10 Offset 10
这篇文章是根据 SQLite 官方 WIKI 里的内容翻译,如果有什么翻译不当的地方希望大家指出,毕竟我的英文水平实在很差。 SQLite
包括以下五个时间函数:
date(日期时间字符串, 修正符, 修正符, ……)
time(日期时间字符串, 修正符, 修正符, ……)
datetime(日期时间字符串, 修正符, 修正符, ……)
julianday(日期时间字符串, 修正符, 修正符, ……)
strftime(日期时间格式, 日期时间字符串, 修正符, 修正符, ……)
上述五个函数需要一个日期时间字符串做参数,后面可以跟零到多个修正符参数。而 strftime() 函数还需要一个日期时间格式字符串做第一个参数。
date() 函数返回一个以 “YYYY-MM-DD” 为格式的日期;
time() 函数返回一个以 “YYYY-MM-DD HH:MM:SS” 为格式的日期时间;
julianday() 函数返回一个天数,从格林威治时间公元前4714年11月24号开始算起;
strft ......
SQLite数据库连接方式
SQLite.NET
Type: .NET Framework Class Library
Usage: System.Data.SQLite.SQLiteConnection
Basic
Data Source=filename;Version=3;
Version 2 is not supported by this class library.
Using UTF16
Data Source=filename;Version=3;UseUTF16Encoding=True;
With password
Data Source=filename;Version=3;Password=myPassword;
Using the pre 3.3x database format
Data Source=filename;Version=3;Legacy Format=True;
With connection pooling
Connection pooling is not enabled by default. Use the following parameters to control the connection pooling mechanism.
Data Source=filename;Version=3;Pooling=False;Max Pool Size=100;
Read only connection
Data Source=filename;Version=3;Read Only=True;
Using DateTime.Ticks as datetime format
Data Source=filename;Version=3;DateTimeFormat=Ticks;
The default value is ISO8601 which activates the use of the ISO8601 datetime format
Store GUID as text
Normall ......