我想在我的asp.net网站上阅读Excel表格.文件由用户上传,然后我阅读它并在网格视图中显示结果.当我在Visual Studio环境中运行它时,每件事都可以正常工作.但是当我在IIS上尝试相同的代码时,它给出了一个例外Unspecified Error.我使用以下代码:
string excelConnection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+Server.MapPath("~/doc/")+ filepath+";Extended Properties="+ "\"" + "Excel 12.0;HDR=YES;" + "\"";
string query = "select * from [Sheet1$]";
OleDbConnection con = new OleDbConnection(connection);
con.Open(); // Exceptionoccurs here
OleDbCommand cmd = new OleDbCommand(query, con);
cmd.CommandType = CommandType.Text;
OleDbDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
testGrid.DataSource = dt;
testGrid.DataBind();
Run Code Online (Sandbox Code Playgroud)
异常堆栈跟踪:
[OleDbException (0x80004005): Unspecified error]
System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +351
System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) …Run Code Online (Sandbox Code Playgroud) Bitmap clip = new Bitmap((int)(8.5 * 72), (int)(11 * 72));
MemoryStream stream = new MemoryStream();
clip.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
byte[] bytes = stream.ToArray();
Run Code Online (Sandbox Code Playgroud)
我跑了它在我的机器上,并且bytes.Length是8587,我的同事开发的机器是2009.据说,.NET没有办法影响PNG压缩的质量(或者说这种情况下的比率).这个特殊的图像是空白的,我还有其他测试与内容图像一起工作,他们确认压缩是无损的(我遇到了一些争论,这是一个问题).
但即使压缩是无损的,压缩算法运行时间+ CPU利用率与压缩率/质量之间也需要权衡.我想知道如何System.Drawing.Imaging确定质量,因为上述情况清楚地表明可能存在差异.我怎么能确定在客户的机器上它不会选择100%的质量(这将产生1.457.337大小的文件)?
相关材料:
附加信息:
所以我正在阅读以下的两列数据txt文件:
20 0.15
30 0.10
40 0.05
50 0.20
60 0.10
70 0.10
80 0.30
我想把第二列放入一个数组({0.15,0.10,0.05,0.2,0.1,0.1,0.3}),但我不知道如何解析大于1的浮点数.我试过在扫描仪中读取文件并使用分隔符,但我不知道如何获取进行令牌的整数.请帮我.
这是我的代码供参考:
import java.io.PrintWriter;
import java.util.Scanner;
import java.io.*;
class OneStandard {
public static void main(String[] args) throws IOException {
Scanner input1 = new Scanner(new File("ClaimProportion.txt"));//reads in claim dataset txt file
Scanner input2 = new Scanner(new File("ClaimProportion.txt"));
Scanner input3 = new Scanner(new File("ClaimProportion.txt"));
//this while loop counts the number of lines in the file
while (input1.hasNextLine()) {
NumClaim++;
input1.nextLine();
}
System.out.println("There are "+NumClaim+" different claim sizes …Run Code Online (Sandbox Code Playgroud) 我有一个DataTables表,在某些标题列中有复选框和弹出窗口.(另外我也使用FixedColumn和ColReorder插件).我在jsfiddle中的模型就在底部
我的问题是,如果用户尝试检查复选框或按下弹出窗口,则排序事件将接管所有内容.jsfiddle页面没有完全运行,因为在我的应用程序中,我收到了复选框点击的事件,但是那时太晚了,排序也会发生.排序图标只是标题单元格的背景CSS,而排序事件是由DataTables为整个标题单元格注册的.
计划解决这个问题:
http://jsfiddle.net/csabatoth/pgue1sf5/8/
var initPage = function () {
var columnsArray = [
{ "title": "index", "class": "dt-center" },
{ "title": "lastname", "class": "dt-head-center dt-body-left" },
{ "title": "firstname", "class": "dt-head-center dt-body-left" },
{ "title": '<div>foo1</div><input type="checkbox" class="filterchk" checked="checked"> <select class="paramsel"><option value="1" selected="selected"/><option value="2"/><option value="3"/></select>', "class": "dt-head-center dt-body-left" },
{ "title": '<div>foo2</div><input type="checkbox" class="filterchk" checked="checked"> <select class="paramsel"><option value="1" selected="selected"/><option value="2"/><option value="3"/></select>', "class": "dt-center rulecolumn" },
{ "title": '<div>foo3</div><input type="checkbox" class="filterchk" checked="checked"> <select class="paramsel"><option value="1" selected="selected"/><option value="2"/><option value="3"/></select>', …Run Code Online (Sandbox Code Playgroud) 我跟着这个:http: //volaresystems.com/blog/post/2013/12/09/Using-Bootstrap-3-radio-button-groups-with-Knockout-3-data-bindings (jQuery 2.0.3,Bootstrap) 3.0.3,淘汰赛3.0.0)
据我所知,唯一的区别是jQuery,Knockout和Bootstrap版本号,但主要版本号匹配. http://jsfiddle.net/csabatoth/rLtL16xk/12/(jQuery 2.1.3,Bootstrap 3.3.4,Knockout 3.3.0)
<p>
Currently selected: <span data-bind="text: selectedOption"></span>
</p>
<div class="btn-group-vertical" data-toggle="buttons">
<label class="btn btn-lg btn-primary" data-bind="css: { 'active': selectedOption() === 'Purchase Target Cat' }">
<input type="radio" name="options" id="option1" data-bind="checked: selectedOption, checkedValue: 'Purchase Target Cat'">Purchase Target Cat
</label>
<label class="btn btn-lg btn-primary" data-bind="css: { 'active': selectedOption() === 'Purchase Existing Cat' }">
<input type="radio" name="options" id="option2" data-bind="checked: selectedOption, checkedValue: 'Purchase Existing Cat'">Purchase Existing Cat
</label>
<label class="btn btn-lg btn-primary" data-bind="css: { …Run Code Online (Sandbox Code Playgroud) javascript jquery radio-button twitter-bootstrap knockout.js
我<%datetime%>在 SendGrid 模板中定义了一个变量。我根据这个命名约定决定遵循已经放置<%subject%>的主题行。我在示例中看到了不同的变量命名约定:https : //github.com/sendgrid/sendgrid-csharp/blob/master/SendGrid/Example/Example.cs#L41使用-name-and -city-,而https://github.com/sendgrid /sendgrid-csharp/blob/master/SendGrid/Example/Example.cs#L157使用%name%和%city%。
我只是假设变量替换基于简单的模式匹配,因此这些示例的对应模板包含完全相同的字符串。到目前为止,无论出于何种原因,这对我都不起作用。
string sendGridApiKey = ConfigurationManager.AppSettings["SendGridApiKey"].ToString();
var sendGrid = new SendGridAPIClient(sendGridApiKey);
string emailFrom = ConfigurationManager.AppSettings["EmailFrom"].ToString();
Email from = new Email(emailFrom);
string subject = "Supposed to be replaced. Can I get rid of this somehow then?";
string emaiTo = ConfigurationManager.AppSettings["EmailTo"].ToString();
Email to = new Email(emaiTo);
Content content = new Content("text/html", "Supposed to be replaced by the template. Can I get …Run Code Online (Sandbox Code Playgroud) c# ×3
jquery ×2
asp.net ×1
datatables ×1
delimiter ×1
iis ×1
java ×1
javascript ×1
knockout.js ×1
png ×1
radio-button ×1
sendgrid ×1