从C#读取Excel文件(Reading an Excel File From C#)
我有一个连接字符串来读取我的C#项目中的excel文件,看起来像这样..
String ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + VariableFile + ";" + "Extended Properties=Excel 8.0;";
我也有objConn.Open(); 打开文件..
问题是我的程序打开文件的唯一时间是如果我手动打开Excel文件并运行我的程序。 任何人都可以帮助我从我的C#代码打开文件,而不必手动打开它。 我收到错误消息:当我尝试运行它时未找到可安装的ISAM,而无需首先打开Excel文件。
谢谢
I have a connection string to read an excel file from my C# project that looks like this..
String ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + VariableFile + ";" + "Extended Properties=Excel 8.0;";
and I also have objConn.Open(); to open the file..
The problem is the only time my program will open the file is if I open the Excel file manually and run my program. Can anyone help me to open the file from my C# code instead of having to open it first manually. I get the error message: Could not find installable ISAM when I try to run it without opening the Excel file first.
Thank you
原文:https://stackoverflow.com/questions/7246413
最满意答案
y轴没有限制(除了数字类型的javascript限制外)
但是,您可能看到的可能是9007199254740992以上的精度损失 - 这不是巧合的17位数(请参阅什么是JavaScript的最高整数值,数字可以达到而不会丢失精度?以及相关问题
Chart.js使用值范围来确定如何缩放条形。 它通过从最大值中减去min并使用差值来实现。
现在,如果所有值都相同,Chart.js会添加一个小数字(0.5)来产生差异并继续使用此差异。
如果添加0.5实际产生差异,那么一切都很好 - 但是如果结果高于9007199254740992,它将大部分被精度限制吞噬,给出0差异并弄乱Chart.js的y轴计算。
当数字高于9007199254740992并且它们的差异不够大时会发生同样的问题(它们基本上将相同的数字向上舍入 - >它们被视为一组相等的值 - > 0.5被添加 - >它主要被吞噬了精度限制)
这是一个快速的价值示例,以及为什么它会起作用/不起作用
// works because there is a (small) difference and the numbers are < 9007199254740992 var a = [9007199254740991, 9007199254740992]; // won't work because there is no difference and the numbers are > 9007199254740992 - 0.5 var b = [9007199254740992, 9007199254740992]; // won't work because there is no difference and the numbers are = 9007199254740992 - 0.5 var c = [9007199254740991.5, 9007199254740991.5]; // works because there is no difference and the numbers are < 9007199254740992 - 0.5 var d = [9007199254740991.4, 9007199254740991.4]; // works because there is a significant difference even though the numbers are > 9007199254740992 var e = [12345678901234567890, 12345678901434567891]; // works because there is a significant difference even though the numbers are > 9007199254740992 var f = [0, 12345678901434567891]; // won't work because there is only a small difference and the numbers are > 9007199254740992 var g = [9007199254740992, 9007199254740993];
简而言之,您的条形图不会渲染,因为您有一组相同(或没有显着差异)的值,并且是9007199254740992 - 0.5或更高。
您可以添加一个虚拟值0来强制它渲染(或者可能添加另一个虚拟系列的0值),确保存在显着差异 - 或者如果所有值都在17位数范围内并且非常彼此接近,只绘制偏移量即表示你有1701和1705 ...图1和5并在工具提示中输入170作为值前缀。
There is no limit on the y-axis (except possibly the javascript limit on the number type)
However, what you are possibly seeing might be a LOSS of precision above 9007199254740992 - which not so coincidentally is a 17 digit number (see What is JavaScript's highest integer value that a Number can go to without losing precision? and the associated problems
Chart.js uses the value range to figure out how to scale the bars. It does this by subtracting the min from the max and using the difference.
Now, if all values are same, Chart.js adds a small number (0.5) to make a difference and proceeds with this difference.
All is well and good if adding this 0.5 actually produces a difference - however if the result is above 9007199254740992, it will mostly get swallowed up by the precision limit giving a 0 difference and messing up Chart.js's y axis calculations.
The same issue happens when the numbers are above 9007199254740992 and their difference is not large enough (they basically round up the same number -> they are treated as a set of equal values -> 0.5 is added -> it mostly get swallowed up by the precision limit)
Here's a quick sample of values and why it will work / not work
// works because there is a (small) difference and the numbers are < 9007199254740992 var a = [9007199254740991, 9007199254740992]; // won't work because there is no difference and the numbers are > 9007199254740992 - 0.5 var b = [9007199254740992, 9007199254740992]; // won't work because there is no difference and the numbers are = 9007199254740992 - 0.5 var c = [9007199254740991.5, 9007199254740991.5]; // works because there is no difference and the numbers are < 9007199254740992 - 0.5 var d = [9007199254740991.4, 9007199254740991.4]; // works because there is a significant difference even though the numbers are > 9007199254740992 var e = [12345678901234567890, 12345678901434567891]; // works because there is a significant difference even though the numbers are > 9007199254740992 var f = [0, 12345678901434567891]; // won't work because there is only a small difference and the numbers are > 9007199254740992 var g = [9007199254740992, 9007199254740993];
In short, your bar is not rendering because you have a set of values that are same (or do not significantly differ) AND are 9007199254740992 - 0.5 or above.
You could just add a dummy value of 0 to force it to render (or possibly add another dummy series of 0 values) by making sure there is a significant difference - or if all your values are going to be in the 17 digit range and very close to each other, just plot the offset i.e. say you have 1701 and 1705... plot 1 and 5 and put in the 170 as a value prefix in the tooltip.
相关问答
更多-
只需在图表配置中使用labels.margin属性即可。 这是API参考 。 Just use labels.margin property in chart config. Here is API Reference.
-
使用d3轴的刻度方法。 由于x轴的刻度格式是时间,因此您可以指定计数和刻度格式。 var xAxis = d3.svg.axis().scale(x).orient("bottom").ticks(d3.time.day, 2); var yAxis = d3.svg.axis().scale(y).orient("left").ticks(5); 您可以从此处参考d3 svg轴以及此处的时间格式 Use ticks method of d3 axis. Since tick format of x a ...
-
我不太清楚你想要输出的样子。 这样的事情会好吗? ggplot(data = data , aes(x = 'COUNTRY', y = count, fill = reorder(country, count)))+ geom_bar(stat = "identity")+ xlab("COUNTRY")+ ylab("TOTAL")+ theme_minimal()+ geom_text(aes(label = sprintf(" ...
-
y轴没有限制(除了数字类型的javascript限制外) 但是,您可能看到的可能是9007199254740992以上的精度损失 - 这不是巧合的17位数(请参阅什么是JavaScript的最高整数值,数字可以达到而不会丢失精度?以及相关问题 Chart.js使用值范围来确定如何缩放条形。 它通过从最大值中减去min并使用差值来实现。 现在,如果所有值都相同,Chart.js会添加一个小数字(0.5)来产生差异并继续使用此差异。 如果添加0.5实际产生差异,那么一切都很好 - 但是如果结果高于9007199 ...
-
D3.js条形图Y轴问题(D3.js bar chart Y-axis issue)[2022-06-02]
您可以对每个用户使用: d.values.reduce(function(sum, d){ return sum + d.amount; },0) 这是减少文档 .- You can use on each user: d.values.reduce(function(sum, d){ return sum + d.amount; },0) Here's reduce documentation.- -
实际上,我认为我找到了一种非常基本和静态的方法来设置宽度。 在chart.js(版本1.0.2)中,第1576行: this.yLabelWidth = (this.display && this.showLabels) ? longestText(this.ctx,this.font,this.yLabels) + 10 : 0; 我只是将其改为静态数字'93'。 this.yLabelWidth = 93; 我肯定会稍微修补一下,我可以调用表格中第一个单元格的宽度,使它们都相同。 Actually, ...
-
“y轴:显示”实际上是针对y轴线本身。 我不认为这与标签本身有关。 我认为echarts正试图将这些标签保留在那里,但他们只是没有显示。 注意:刚下班回家,我原来的答案不起作用。 你在使用网格吗? 我只是测试它,并使用这样的东西: myChart.setOptions({ grid: { left: '15px', right: '15px' }, .........(add more options as needed here) } "y-axis: sho ...
-
NVD3 Javascript库引用他们的网站,“尝试构建可重复使用的图表和图表组件”。 它的创建者做了几个关键决定,以强调图表的可重用性: 他们专注于实施标准图表设计(折线图,条形图,散点图),但以灵活,互动的方式实施。 他们对所有图表使用了相同的数据结构要求: 主数据阵列包含多个数据系列,每个数据系列代表数据的逻辑分组; 每个系列都是包含两个或多个变量的单个数据对象的数组。 所有图形都具有相似的样式并重用重要的代码片段。 NVD3库允许您创建分组条形图或堆积条形图,甚至可以创建两者之间交互式动画的图表 ...
-
将X轴最小可见值设置为使条形可见的值: renderer.setXAxisMin(-0.5); Set the X axis minimum visible value to something that will make the bar visible: renderer.setXAxisMin(-0.5);
-
如果要控制图表的高度,可以更改画布的高度 或者如果您想更改y轴值的高度,请尝试以下操作。 下面将确保栏的最大尺寸为25000,每一步为5000,回调将标记为5k,10k,15k,20k,25k var chartConfig = { type: 'bar', data: data, options: { scales: { ...