|
Hey,
I want to create a .xlsx file based on data from a grid.
My problem: I have values like 01234 (starts with zero) exporting them make 1234 ... so, how can I export it with right format?
I fill the file with:
if (Excelpfad == "")
return false;
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook newWorkbook = excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Sheets excelSheets = newWorkbook.Worksheets;
string currentSheet = "Tabelle1";
Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(currentSheet);
for (int i = 0; i < UsingGrid.Cols; i++)
{
for (int j = 0; j < UsingGrid.Rows; j++)
{
worksheet.Cells[j + 1, i + 1] = Convert.ToString(UsingGrid[j, i]);
}
}
for (int iExcel = 0; iExcel < UsingGrid.Cols; iExcel++)
{
((Microsoft.Office.Interop.Excel.Range)worksheet.Columns[iExcel + 1, t]).ColumnWidth = UsingGrid.get_ColWidth(iExcel) * 0.13171875;
}
if (Excelpfad.Substring(Excelpfad.LastIndexOf(".")) == ".xls")
worksheet.SaveAs(Excelpfad, Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
else if (Excelpfad.Substring(Excelpfad.LastIndexOf(".")) == ".xlsx")
worksheet.SaveAs(Excelpfad, t, t, t, t, t, t, t, t, t);
and another question: how can I close that file correct?
I have:
newWorkbook.Close(true, n, n);
excelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet);
but the "EXCEL.EXE" process still run
thank you
|
|
|
|
|
Mschauder wrote: for (int j = 0; j < UsingGrid.Rows; j++) { worksheet.Cells[j + 1, i + 1] = Convert.ToString(UsingGrid[j, i]); } }
first question:
something like:
r.NumberFormat = "@";
Note this is language specific(system language and settings).
Best way to do it is record a macro while you set the Format to text and look at the VBA produced and
translate it to C#. This silly article is especially about formatting. And the export is a lot faster than the cell by cell aproach.
|
|
|
|
|
Hi,
I am allowing user to select datetime in datetimepicker in "dd/MM/yyyy" format but when it stores in sqlserver 2005 it store as "mm/DD/yyyy", but i want it store as "dd/MM/yyyy" format in SqlServer 2005, how can i do that OR When i filter records, it should be in "dd/MM/yyyy" format ?
Regards,
XYZ
|
|
|
|
|
The internal format used to store a date time has nothing to do with how it is serialized as a string. Both SQL and C# have techniques for serializing date/times. In particular, you'll want to look into DATEPART and CONVERT for SQL and ToString and String.Format for C#. The C# DateTime also has several methods that allow you to serialize to different common formats.
|
|
|
|
|
Write in SQL Select Query
Select Convert(varchar(10),getdate(),103) Like this will return dd-MM-yyyy
And in C# use .ToString("dd-MM-yyyy");
In grid use DataFormatString Property and make sure HTMLEncode="False" set in That columnBest Regards,
Chetan Patel
|
|
|
|
|
I already know how to do that... you might want to reply to the OP to tell him/her what you've told me. Though, to be honest, I think I gave him/her enough information already.
|
|
|
|
|
you might want to read this[^].
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hello,
I get Error when i setup my service.
Error NUM 1001-Your password or your user is incorrnet.
SOMEBODY CAN TO HELP ME?WHAT TO DO?
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:09am.
|
|
|
|
|
|
How to uninstall a program from Add/Remove Programs. Please guide me to achieve this programmatically. Thanks in advance.
|
|
|
|
|
Found this here[^].Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
|
You are basically asking the same question again. What have you tried? What API are you using to interact with video? What is your actual problem? Be more specific.
|
|
|
|
|
I am basically gathering information yet. As i told you that i dont have any idea of multimedia in C#. So i need the full information. Googling lead me to DirectShow .net library. Is this library enough for my requirements. What i need is:
We have a in-house channels of Movies. We want to play ads in that channel. The ads can be a:
1) standalone ad
2) A strip (like news headlines in various channels)
3) An L-shaped ad (like shown in some sports channels)
these ads will be in swf/avi/wmv/mp4 etc formats.
In addition, we want to have a scheduler for playing movies(basically a queue)/ads(managed on timely based)/Logo(for the in-house channel i.e an image or an animated image or video format).
These are the basic requirements for the project.
I want to learn multimedia coding in c#, so need a kind response.
Regards.modified on Thursday, February 25, 2010 11:24 PM
|
|
|
|
|
Hi.
I'm C# developer. I want to know possible write app in C# for mobile phones ?
(IPhone , Google phone , Nokia , Samsung , Motarolla , SonyEricson , LG and ...)
Thanks.We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:09am.
|
|
|
|
|
Thanks for reply.
What mean of "a third party library" ?
Thanks.We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
It means that library was created by other people/company. Some phones uses JAVA
|
|
|
|
|
I develop apps for the iPhone. I have to use Apples iPhone SDK to create and compile the application. Apple does not support C# but instead use Xcode for iPhone apps. So in this example, the third-party library would be the iPhone SDK.
I hope this helps.
|
|
|
|
|
Thank you guys . We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
Hi folks,
I'd like your comments on the following requirement...
I need to create a TIF image or PDF file based on a structured layout from a data file.
The data file has the required values to be plug on the form to be converted into TIF or PDF.
For example, the data file will have the invoice values as displayed here[^]. Of course, the data file will contain several records which corresponds to one single image or PDF per record.
The app is to be written as an unattended console app, so it parses the data file, exports the images to a network folder and sends a notification once is finished.
How do you suggest to implement this requirement?
I thought about...
* Creating Crystal reports, but not sure if you can create them from a console app.
* Creating HTML source for the layout, and print them to either TIF or PDF somehow.
Your support is highly appreciated.
Thanks,
...Alex
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:10am.
|
|
|
|
|
Great!
It seems the MigraDoc[^] component will work on this scenario.
Thank you,
...Alex
|
|
|
|
|
Hey,
I'm suffering an issue of reading and displaying a huge text file (>=300MB) in a textbox.
I found that the maximum string I can read into memory is about 250MB because of the limitation of the RAM and also likely related to the limitation of the .net component. (when the text is very large to display in a textbox, out of memory exception will be thrown)
So in this case, the only way we can do is to show the text file on demand, which is likely what the UltraEdit does.
Could anyone give me some tips or solutions about this issue?
Thanks in advance.
dengbo---------------------------------
Believe what you saw!
|
|
|
|